Access VBA Dot vs. Bang Operator for Controls and Fields
Question details
The user wants to understand when to use dot and bang operators for controls and fields in Access VBA.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Writing form code that refers to controls or fields, including when a form's record source changes.
- Observed behavior
- The goal is to write clear references that distinguish form controls from fields in the current recordset.
Identify the control names and record source fields used by the form. Open the form's VBA module, and confirm that the form is bound and has a current record before testing recordset field references.
Use explicit control and field references in Access VBA
Use explicit collections when you want the code to clearly distinguish a form control from a recordset field.
The dot operator accesses an object's members, while the bang operator commonly identifies a named item in a default collection. Access forms can expose both controls and fields through shorthand, so an explicit collection is clearer when names overlap or a record source changes.
In Access, open the form in Design View and use View Code to open its VBA module.
In a form procedure, use Me.Controls("CustomerName").Value to read the value of a control named CustomerName. Me.CustomerName.Value is a shorter dot-style reference when Access resolves that name to the intended control.
Use Me.Recordset.Fields("CustomerID").Value to read the CustomerID field from the form's current recordset. Replace CustomerID with a field present in the current record source.
In the VBA editor, choose Debug > Compile, then open the form and run the procedure. If the record source changes, test again with a current record and verify that the required field exists.

Use bang syntax for named collection items
Use bang syntax as a concise alternative when referring to named controls or fields.
Use WPS Office for everyday documents and spreadsheets
WPS Office is a free, lightweight alternative with a familiar interface and compatibility with common Office files, making it easy to move everyday documents and spreadsheets. It does not replace Microsoft Access or fix Access VBA code.

Frequently Asked Questions
Does the bang operator always refer to a recordset field?
No. Bang identifies a named item in a collection, so its meaning depends on the object before it. For example, Me.Controls!CustomerName refers to a control, while Me.Recordset.Fields!CustomerID refers to a field.
What happens if a form's record source changes?
A field reference can fail if the new record source does not contain that field. Use Me.Recordset.Fields("FieldName") to make the intended lookup clear, and test the procedure after changing the record source.
Will deleting a control always cause a compile error?
No. Some dot-style references can be caught when you choose Debug > Compile in the VBA editor, but detection depends on how Access resolves the reference. Named collection lookups generally report a missing item at runtime.
Is dot syntax faster than bang syntax in Access VBA?
Any performance difference is usually insignificant for ordinary form code. Choose a consistent style that makes it clear whether you intend to access a control or a field.




