Avatar of SteveL13
SteveL13
Flag for United States of America

asked on 

Advise on best way to handle multiple checkboxes

I'm looking for the best way to handle multiple Yes/No checkboxes.  If one is checked, true, the others have to be unchecked, false.  There are 5 individual checkboxes on the form.  I have the following code but it seems odd to have to have this code on each checkbox's afterupdate or onchange event.  Right?

    If Me.chkbx1 = True Then
        Me.chkbx2 = False
        Me.chkbx3 = False
        Me.chkbx4 = False
        Me.chkbx5 = False
    End If
        
    If Me.chkbx2 = True Then
        Me.chkbx1 = False
        Me.chkbx3 = False
        Me.chkbx4 = False
        Me.chkbx5 = False
    End If
        
    If Me.chkbx3 = True Then
        Me.chkbx1 = False
        Me.chkbx2 = False
        Me.chkbx4 = False
        Me.chkbx5 = False
    End If
        
    If Me.chkbx4 = True Then
        Me.chkbx1 = False
        Me.chkbx2 = False
        Me.chkbx3 = False
        Me.chkbx5 = False
    End If
        
    If Me.chkbx5 = True Then
        Me.chkbx1 = False
        Me.chkbx2 = False
        Me.chkbx3 = False
        Me.chkbx4 = False
    End If

Open in new window


--Steve
Microsoft Access

Avatar of undefined
Last Comment
PatHartman

8/22/2022 - Mon