Only One checkbox Allowed (1 Viewer)

rgwfly

Registered User.
Local time
Today, 07:11
Joined
Jun 7, 2016
Messages
49
I searched and sure the answer is there. I have a sub-form with multiple
checkboxes. Would like to select one and only one.
I know I can set the on OnClick event to clear the others. I was curious if there is a better way.
 

Mark_

Longboard on the internet
Local time
Today, 07:11
Joined
Sep 12, 2017
Messages
2,111
Have you though about using an Option control?
 

rgwfly

Registered User.
Local time
Today, 07:11
Joined
Jun 7, 2016
Messages
49
Yes I did. This puts different values (1,2,3) on each option instead of a true false.
I should have used this on initial design.
 

Mark_

Longboard on the internet
Local time
Today, 07:11
Joined
Sep 12, 2017
Messages
2,111
As an "After the fact", after update you set all of your check boxes to false and have a select case based off of your option to set ONLY the one you want to true.

Does mean you would need to check your checkboxes on the way in to select the proper option though.
 

Mark_

Longboard on the internet
Local time
Today, 07:11
Joined
Sep 12, 2017
Messages
2,111
Example "Air code"
Code:
Sub Clear_CB
   Me.Cb01 = False
   Me.Cb02 = False
.
.
.
End Sub

Sub Set_CB
   Clear_CB
   Select Case
   of 1
      Me.Cb01 = True
   of 2
      Me.Cb02 = True
.
.
.
   End Select
End Sub

Sub Set_Option
   If Me.CB01 = True then Me.Option = 1
   If Me.CB02 = True then Me.Option = 2
.
.
.
End Sub

Fairly straight forward. This also avoids the whole "What happens if more than one is set" issue as it will reset to the "Last" in the order you choose.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:11
Joined
May 7, 2009
Messages
19,233
you already have the answer and is the best so far (post #1).
 

Users who are viewing this thread

Top Bottom