How to Make an Access Record Read-Only When Status is Paid
Question details
The user wants to prevent edits to a Microsoft Access form and its associated order-item subform when the OrderStatus field indicates the order has been 'Paid'.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Managing order records where completed or paid orders must be locked dynamically to prevent accidental data modification.
- Observed behavior
- Applying locking logic to both the main form and the subform causes conflicting code and 'Method or Data member not found' errors, failing to properly secure the record.
Before modifying your VBA code, open your form in Design View and verify the exact Name property of your status control in the Property Sheet, as this name must match the one referenced in your VBA script.
Apply VBA Logic to the Main Form's On Current Event
The most reliable way to lock a record based on a field's value is to evaluate the condition exclusively in the main form's On Current event.
Applying read-only logic directly to both the main form and its subform often causes conflicts or triggers a 'Method or Data member not found' error. Placing the AllowEdits logic exclusively in the main form properly controls the read-only state for both.
Navigate to the Navigation Pane in Access, right-click your main Order form, and select 'Design View'.
Ensure the form itself is selected. Open the Property Sheet, go to the 'Event' tab, find the 'On Current' event, click the ellipsis (...) button, and choose 'Code Builder'.
In the VBA editor, type the following code between Private Sub Form_Current() and End Sub: If Me.OrderStatus.Value = "Paid" Then Me.AllowEdits = False Else Me.AllowEdits = True
Save your VBA module, switch the form back to 'Form View', and navigate through your records to verify that forms marked as 'Paid' are uneditable.

Remove Conflicting VBA Code from the Subform
If you previously added locking logic to the subform, it must be removed to allow the main form to manage the edit permissions without errors.
Looking for a Lightweight Office Suite? Try WPS Office
While Microsoft Access is a powerful specialized database tool, handling your daily documents, spreadsheets, and presentations doesn't require a heavy or expensive Office suite. WPS Office offers a free, lightweight alternative for your Word, Excel, and PowerPoint files with a highly familiar interface.

Frequently Asked Questions
Why do I get a 'Method or Data member not found' error in my Access VBA?
This error generally occurs when your VBA code references a control name that does not exist on the currently active form. Check your Property Sheet to ensure your code uses the control's exact 'Name' property, which is sometimes different from the table's field name.
Does setting AllowEdits to False on the main form automatically lock the subform?
Yes, in most configurations, when you lock the main form by setting Me.AllowEdits = False, Microsoft Access restricts edits to the data in both the main form and any natively bound subforms.
How can I allow users to add new records while keeping 'Paid' records read-only?
You can use Me.AllowAdditions = True in your VBA script alongside your AllowEdits logic. To prevent locking up a blank new record, check the Me.NewRecord property first, allowing edits if the record is completely new.
What if my status field is a combo box looking up values?
If the status field is a combo box, you must evaluate its bound column. If the bound column stores a numeric ID instead of the text string 'Paid' (for example, 2), your VBA condition needs to check for that specific ID: If Me.OrderStatus.Value = 2 Then.




