Access 2013 All-in-One For Dummies
Book image
Explore Book Buy On Amazon

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.”

About This Article

This article is from the book:

About the book authors:

Alison Barrows is the author or coauthor of several books about Access, Windows, and the Internet. Joseph Stockman is an 18-year software designer who has authored or coauthored five Access programming books. Allen Taylor is a 30-year veteran of the computer industry and the author of over 20 books.

This article can be found in the category: