arsarc
arsarc

Reputation: 453

Enabling only one checkbox in a row in Access Multiple Item Form

I have a multiple item form, where most of the checkboxes are disabled unless the user checks the box before it.

Currently I'm using:

If Me.Field1 Then
    Me.chxField2.Enabled = True
Else
    Me.chxField2.Enabled = False
End If

But if I check the box, it enables the Field2 checkbox for all of them, I only want it to enable the checkbox for one particular row.

enter image description here enter image description here

Is this possible to do? If it isn't, that's ok but I just had to ask.

Edit: Thanks to Erik I did this in the BeforeUpdate like he described, and it gives the effect I wanted:

Private Sub chxField2_BeforeUpdate(Cancel As Integer)
    Cancel = Not Field1
    chxField2.Undo
End Sub

Upvotes: 1

Views: 1247

Answers (1)

Erik A
Erik A

Reputation: 32632

Unfortunately, it's not (as far as I know).

On a continuous form, there's actually only one instance of each control. This means that you can't have one of those Field2 checkboxes enabled, and another disabled.

Things you can do:

Use the Checkbox_BeforeUpdate event to check if Field1 is checkded. If it isn't checked, then rollback the change:

Private Sub Field2_BeforeUpdate(Cancel As Integer)
    Cancel = Not Field1
End Sub

Also, if you weren't using a checkbox, you would be able to use conditional formatting to give the control a "disabled look". Unfortunatlely, conditional formatting doesn't apply to checkboxes.

Upvotes: 2

Related Questions