Learn more with dummies

Enter your email to join our mailing list for FREE content right to your inbox. Easy!

By Joseph C. Stockman, Alan Simpson

Part of Access 2007 VBA Programming For Dummies Cheat Sheet

This list shows you the most common jobs carried out in VBA 2007 and the code statements you need to type to complete the VBA task, so keep this list handy:

Open a form in Form view:

DoCmd.OpenForm "formname", acNormal

Change a form property on an open form:

Forms![formName].propertyName = newValue

Get value from a control on an open form:

Forms![formName]![controlName].Value

Change value of a control on an open form:

Forms![formName]![controlName].Value = newValue

Change a control property on an open form:

Forms![formName]![controlName].propertyName = newValue

Close a form, saving design changes:

DoCmd.Close acForm, "formName", acSaveYes

Print a report:

DoCmd.OpenReport "reportName", acViewNormal

Run an action query:

DoCmd.RunSQL "SQLstatement"

Show a simple message:

MsgBox "yourMessage"

Ask a question on-screen:

variable = MsgBox("yourMessage", vbQuestion + vbYesNo)