Help with checkboxes

G

Guest

I have 5 checkboxes and I was wondering if I could make it so that when one
checkbox is ticked all the others can't or with some only certain ones can be
ticked

Morning
Afternoon
Evening
Evening Extension
Special Booking

When morning is ticked nothing else can be ticked
Same for afternoon
When evening is ticked only evening extension can be ticked aswell
And finally when special booking is ticked evening extension is ticked
automatically

If anyone could help I would be very grateful
 
L

Larry Daugherty

In the After_Update event of each checkbox put the code that sets the
state of every other checkbox. that you want to set to a given state.

HTH
 
J

John Nurick

It sounds as if a combination of option buttons and checkboxes would fit
the Windows UI guidelines better. Option buttons are intended for
situations where the user can only choose one of two or more options,
and checkboxes for where the options are independent of each other.

So maybe you need
Option group buttons for Morning, Afternoon, Evening
Checkboxes for Evening Extension and Special Booking
and code along these lines:

When Morning or Afternoon is selected, both checkboxes are disabled.
When Evening is selected, both checkboxes are enabled.
When Special Booking is checked, Evening Extension is automatically
checked.


In the option group's Change event, it would be something like this:
Select Case ogTimePeriod
Case 0, 1 'Morning,
ckEveExtension.Value = False
ckEveExtension.Enabled = False
ckSpecialEvent.Value = False
ckSpecialEvent.Enabled = False
Case Else 'Evening
ckEveExtension.Enabled = True
ckSpecialEvent.Enabled = True
End Select

In ckSpecialEvent_Change, something like this:

Me.ckEveExtension.Value = Me.ckSpecialEvent.Value

Depending on the exact behaviour you want, it may be better to use the
Exit or After_Update events instead of Change.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top