Checkboxes on Forms

  • Thread starter Thread starter Maria L
  • Start date Start date
M

Maria L

Does anyone know of a method of toggling between
checkboxes? For example if the user checks the checkbox -
"Whole Day" then checks the Checkbox "1/2 Day" the
checkbox Whole Day will automaticall be unchecked.
 
Yes, although this would normally be radio buttons. Normally, you could
select more than one check box. I have seen check boxes used for this
though.

1) You can place the checkboxes in an Option Group. The option group will
only allow one item to be selected at a time. You will get a single value
out from this, the value of the Group, not the individual controls in the
group.

2) In the AfterUpdate event of the check boxes, set the other check box(es)
to False. This will allow all to be False, but not more than one to be True.
You could adjust the code to change this behavior.

Example:
Private Sub chkCheckbox2_AfterUpdate
If Me.chkCheckbox2 = True Then
Me.chkCheckbox1 = False
Me.chkCheckbox3 = False
'more checkboxes here as needed.
End Sub

You would do this for each check box.
 
-----Original Message-----
Does anyone know of a method of toggling between
checkboxes? For example if the user checks the checkbox -
"Whole Day" then checks the Checkbox "1/2 Day" the
checkbox Whole Day will automaticall be unchecked.
.
Hi Maria,
the easiest way to achieve this is using the control
wizard when you place an option group control on your
form. The option group will have the effect that you
require. This assumes that you have a single field that
stores that response.

Where you have for some reason (usually poor design)
created more than one field to store alternate values you
can use the following as an example.

private sub chkWholeDay_AfterUpdate()
chkHalfday=not chkWholeDay
end sub

Just reverse this for the other checkbox.

As an asside, convention suggests that checkboxes are
independant. That is users can select one or more option.
Radio button/option buttons are usually dependant. That
is users can only select one.

Luck
Jonathan
 
Back
Top