How to Run the Query Wizard in Access 2013
How to Import Data Sources in Access 2013
How to Create a Navigation Form in Access 2013

Changing Form Controls with VBA in Access 2013

When an Access 2013 database form is open, you can use VBA code to change the contents and even the appearance of the form, from the big picture down to the individual controls.

Suppose that you have a form that includes a control for choosing a payment method. When the user chooses a payment method, you want to enable or disable other controls on the form based on the selected payment method. Alternatively, you may want to autofill some other controls on the form or even make some controls visible or invisible, depending on which payment method the user selected.

Within VBA, use the following syntax to change a control’s property:

ControlName.PropertyName = Value

ControlName is the complete name of a control on an open form, PropertyName is the name of the property that you want to change, and Value is the new value for the property. A dot separates the control name from the property name. The complete name means that the name has to contain both the name of the form and the name of the control. In a class module, however, you can use the keyword Me to stand for the form name. The keyword Me means “the form to which this class module is attached.”

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
How to Start the Report Wizard in Access 2013
10 Things You Need to Know about Relationships in Access 2013
How to Set Table Relationships in Access 2013
Access 2013 For Dummies Cheat Sheet
How to Create a New Access 2013 Form