Toggle a Form’s AllowEdits Property with VBA in Microsoft Access
Question details
Use a form button to switch the AllowEdits property between True and False each time it is clicked.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A user wants to enable or prevent edits to existing records from a form button.
- Observed behavior
- Each button click should reverse the form’s current AllowEdits setting.
Open the database in Microsoft Access and make sure the form’s record source is updatable. If Access displays a security warning, enable content only if you trust the database so its VBA code can run.
Use a command button to toggle AllowEdits
Add a standard command button whose Click event reverses the form’s AllowEdits property.
Open the form in Design View, then use Design > Button to add a standard command button to the form.
Select the button, open its Property Sheet, and on the Event tab set On Click to [Event Procedure]. Click the ellipsis button to open the VBA editor.
Inside the generated Click procedure, enter `Me.AllowEdits = Not Me.AllowEdits`. For a button named Command131, the complete procedure is: Private Sub Command131_Click() Me.AllowEdits = Not Me.AllowEdits End Sub
Save the form and open it in Form View. Click the button to disable edits to existing records, then click it again to re-enable them.

Work with Office files in WPS Office
WPS Office is a free, lightweight alternative for documents, spreadsheets, and presentations. Its familiar interface and support for common Office formats make it easy to move everyday file work to WPS. Microsoft Access databases and their VBA form events still require Access.

Frequently Asked Questions
Why use a command button instead of a toggle button?
A toggle button may become unavailable when the form’s AllowEdits property is False. Use a standard command button with a Click event to switch the property back on.
Why can’t I edit records after setting AllowEdits to True?
The form’s record source must also be updatable. Check the form’s Record Source in its Property Sheet and test the underlying table or query for editability.
Does AllowEdits also prevent new records or deletions?
AllowEdits controls edits to existing records. Use the form’s AllowAdditions and AllowDeletions properties to control adding and deleting records separately.
How can I change the button caption to show the current action?
After toggling AllowEdits in the button’s Click procedure, set the button’s Caption to an appropriate label, such as “Lock editing” when AllowEdits is True and “Enable editing” when it is False.




