VBA & Macro Problems

Access VBA Dot vs. Bang Operator for Controls and Fields

Rana GarciaRana Garcia Nov 22, 2026 868 views

Question details

The user wants to understand when to use dot and bang operators for controls and fields in Access VBA.

Access VBA Dot vs. Bang Operator for Controls and Fields
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the form module

In Access, open the form in Design View and use View Code to open its VBA module.

2
Reference a control

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.

3
Reference a recordset field

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.

4
Compile and test

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 explicit control and field references in Access VBA
Check names and errors: Some dot-style references can reveal missing members at compile time, while collection lookups generally fail at runtime if a name is missing. Error detection depends on how the object and reference are resolved.
Free Microsoft Office alternative

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.

Work with spreadsheet data in a familiar interface alongside your Access projectsOpen and edit common Microsoft Office formats, including XLSX, DOCX, and PPTXUse a lightweight office suite for everyday document and spreadsheet tasks
microsoft office alternative - wps office

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.