Office Settings & Configuration

How to Lock or Hide Form Controls in MS Access using VBA

Elise WilliamsElise Williams Nov 3, 2026 869 views

Question details

The user wants to know how to restrict editing or hide specific form controls in a Microsoft Access database dynamically using VBA.

How to Lock or Hide an Access Control with VBA
Product
Microsoft Access
Device & OS
not provided
Scenario
Securing or adapting database forms by dynamically hiding or locking fields based on user input or events.
Observed behavior
Users need to manage the accessibility of form controls, as Access table fields cannot be locked directly.
Before you start

Ensure you have your Microsoft Access database open in Design View and have basic familiarity with the VBA environment. Note the exact names of the form controls you wish to modify from the Property Sheet.

Solution 1Recommended

Use VBA Properties to Lock, Disable, or Hide Controls

Apply VBA code to specific form events (such as After Update) to change control states dynamically.

In Microsoft Access, you cannot apply lock or hide settings directly to table fields. Instead, you apply these settings to the controls located on your forms using VBA properties: 'Locked', 'Enabled', and 'Visible'.

1
Open Form in Design View

Right-click your form in the navigation pane and select 'Design View'.

2
Select the Trigger Control

Click the control that will trigger the change (for example, an input field named 'Amount').

3
Access the Event Tab

Open the Property Sheet (F4), navigate to the 'Event' tab, and click the ellipsis (...) next to the 'On After Update' property.

4
Open Code Builder

Choose 'Code Builder' from the prompt to open the VBA editor.

5
Insert VBA Code

Type the following VBA code inside the generated subroutine: `If Me.Amount > 0 Then Me.Amount.Locked = True End If`. To hide the control instead, use `Me.Amount.Visible = False`. To grey it out completely, use `Me.Amount.Enabled = False`.

Use VBA Properties to Lock, Disable, or Hide Controls
Correct Control Names: Remember to replace 'Amount' in the code snippet with the actual Name property of your control as listed in the Property Sheet.
Free Microsoft Office alternative

Looking for a Free Office Suite? Try WPS Office

While Microsoft Access is used for complex database management, most of your daily documentation, data analysis, and presentation tasks can be handled efficiently with WPS Office. It provides a highly compatible, lightweight alternative to Word, Excel, and PowerPoint.

Fully compatible with Microsoft Office formats like .docx, .xlsx, and .pptxLightweight architecture ensures fast startup even on older hardwareFamiliar tabbed user interface minimizes the learning curveIncludes an integrated PDF editor and powerful AI writing assistants
microsoft office alternative - wps office

Frequently Asked Questions

What is the difference between Locked and Enabled in Access VBA?

Setting 'Locked = True' prevents the user from editing the data, but the control still looks normal and can receive focus, allowing users to copy the text. Setting 'Enabled = False' greys out the control entirely, preventing any interaction, editing, or focus.

Can I lock an entire table column directly in MS Access?

No, Microsoft Access does not allow you to lock table fields directly at the table design level. To restrict data entry, you must place controls on a Form and apply the Locked or Enabled properties to those specific form controls.

How do I make a hidden control visible again?

You can use VBA to reverse the visibility state. For example, assign `Me.ControlName.Visible = True` to a button's On Click event, or use an `Else` statement in your existing VBA logic to restore visibility when conditions change.