If a checkbox is true then unlock another check box?

NocMed

New member
Local time
Today, 15:09
Joined
Nov 25, 2009
Messages
1
Hi guys, new to forum and searched but couldnt find my problem so here it goes:

Im trying to make a basic form to make the task of inputting some data faster.

Say we are looking at the types of food a person eats
there are checkboxes on the form which add a true/false value in a table if checked/unchecked.

e.g checkbox 1: is FRUIT
checkbox 2 is: MEAT

but i also have checkbox 1a: APPLE 1b ORANGE

and checkbox 2a: HAM 2b: CHICKEN

how can i make it such that checks boxes of the subtype of food (1a, 1b, 2a, 2b) are faded or locked unless the parent checkbox (the category of food) is checked?

So would be great if some one can translate this into VB code for me? e.g

"if fruitcheckbox = checked
then APPLEcheckbox and orangecheckbox are active
else applecheckbox and orangecheckbox are faded.

and likewise if meat is checked then ham and chicken are active else they are faded...
Many thanks for you time.
 
Last edited:
This is the basic structure of an IF to aenable or disable based on other entries. This procedure could be used on the AfterUpdate of the bread checkbox.

Code:
If BREADcheckbox Then
   APPLEcheckbox.Enabled = True 
   orangecheckbox.Enable = True
Else 
   applecheckbox.Enabled = False
   orangecheckbox.Enabled = False
End If

It is hard to say without seeing the project but you may be better using cascading comboboxes. These are well described on this site and others.

It would be better to put the combinations in tables and use these records to generate the checkbox enabling logic.
 

Users who are viewing this thread

Back
Top Bottom