[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

Access checkbooks controlled via vba

Hello Experts,

I have a continous form with 8 checkboxes. For each record, I want to disable the unchecked checkboxes when the user checks 4 out the 8 checkboxes. How do I do it?

The name of the checkboxes is chk1, chk2, chk3, etc...

Thank you
1 Solution
You can use this sub:
Sub chkboxes()
Dim S As Integer, i As Integer
S = 0
For i = 1 To 8
    S = S - Nz(Me("chk" & i), 0)
Next i
If S = 4 Then
  For i = 1 To 8
        If IsNull(Me("chk" & i)) Or Me("chk" & i) <> True Then Me("chk" & i).Enabled = False
  Next i
  For i = 1 To 8
    If Me("chk" & i).Enabled = False Then Me("chk" & i).Enabled = True
  Next i
End If
End Sub

Open in new window

Call it from after update event in all check boxes:
Private Sub chk1_AfterUpdate()
End Sub

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now