
The fastest way to set a property of a control is from within an object's module by using the object's Me property. The following examples set the Visible property of a text box called CustomerID on the Customers form: ' Faster method.įorms!Customers.Controls!CustomerID.Visible = True
#Access vba expected named parameter openform formname code#
Refer to the Controls collection either implicitly or explicitly, but the code executes faster if you use an implicit reference. Refer to the control in the Controls collection of the Form or Report object on which it resides. For example, to set the RecordSource property of the Customers form to an SQL statement that returns all records with a CompanyName field entry beginning with "A" from within the Customers form module, use the following line of code: Me.RecordSource = "SELECT * FROM Customers " _ Code that uses the Me property executes faster than code that uses a fully qualified object name. You can also set a property of a form or report from within the object's module by using the object's Me property. For example, to set the Visible property of the Customers form to True (-1), use the following line of code: Forms!Customers.Visible = True Refer to the individual form or report within the Forms or Reports collection, followed by the name of the property and its value. You can also set properties for form and report sections. You can set properties for these objects from within a Sub, Function, or event procedure. Form, Report, and Control objects are Access objects.
