Enable and Require a Field Based on a Checkbox in Microsoft Access
Question details
Enable Field B only when Field A is checked, and require a value in Field B before saving.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- An Access form contains a checkbox named FieldA and a dependent field named FieldB.
- Observed behavior
- FieldB should be disabled when FieldA is unchecked. When FieldA is checked, FieldB should be enabled and the user should be prompted if it is empty.
Open the form in Design View and confirm the control names on the Property Sheet. The example assumes FieldA is a checkbox and FieldB is a text control; replace those names in the code if yours differ.
Use Form Events to Enable and Validate Field B
Keep FieldB synchronized with the checkbox and validate it when the user saves the record.
The form's Current event sets the correct state when you move between records, while FieldA's After Update event responds to checkbox changes. The form's Before Update event prevents a record from being saved when FieldA is checked and FieldB is blank.
For conditional validation, make sure the underlying FieldB table field is not set to Required: Yes; otherwise, Access will require it even when FieldA is unchecked.
Open the form in Design View, select FieldB, and set Enabled to No on the Property Sheet's Data tab. If new records should start with FieldB disabled, set the FieldA checkbox's Default Value to False.
Select FieldA, open the Property Sheet's Event tab, set After Update to [Event Procedure], and click the ellipsis button. In the VBA editor, use: Private Sub FieldA_AfterUpdate() Me.FieldB.Enabled = Nz(Me.FieldA.Value, False) End Sub
Select the form using the form selector, then set its On Current event to [Event Procedure] and click the ellipsis button. Add: Private Sub Form_Current() Me.FieldB.Enabled = Nz(Me.FieldA.Value, False) End Sub
On the form's Event tab, set Before Update to [Event Procedure] and click the ellipsis button. Add: Private Sub Form_BeforeUpdate(Cancel As Integer) If Nz(Me.FieldA.Value, False) Then If Len(Trim(Nz(Me.FieldB.Value, ""))) = 0 Then MsgBox "Enter a value in Field B before saving.", vbExclamation Cancel = True End If End If End Sub
Save the form and switch to Form View. Check FieldA, leave FieldB empty, and try to save or move to another record; then enter a value and try again. Also verify that FieldB is disabled when FieldA is unchecked and that its state updates as you navigate records.

Work With Office Documents in WPS Office
WPS Office is a free, lightweight alternative for everyday documents and spreadsheets, with a familiar interface and Microsoft Office format compatibility to make migration easier. It does not replace Microsoft Access or run Access form events.

Frequently Asked Questions
Why does FieldB stay disabled when I open an existing record?
Add the Form_Current event shown above. It updates FieldB.Enabled whenever the form opens or moves to another record, based on that record's FieldA value.
How can I make FieldB disabled on a new record?
In Design View, set FieldA's Default Value to False and FieldB's Enabled property to No. The Form_Current event will then keep the control state aligned with the checkbox.
Will Access still require FieldB when FieldA is unchecked?
Not with the form validation shown, but a table-level Required: Yes setting can still require it. Check FieldB's properties in table Design View and use Required: No for this conditional rule.
Does the validation code work for a numeric FieldB?
The example checks a text control and treats spaces as empty. For a numeric control, replace the text check with IsNull(Me.FieldB.Value); zero is a value and should be handled separately if it is not allowed.




