Codes for Common VBA 2007 Tasks

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)








dummies

Source:http://www.dummies.com/how-to/content/codes-for-common-vba-2007-tasks.html

No comments:

Post a Comment