Enabled combo boxes w/in subform

G

Guest

I have a check box and two combo boxes within a subform. I would like to
disable my combo boxes until the check box is checked. I have been able to do
this with my subform, but when I add a new record to my main form the cbo
boxes stay enabled. What would the code look like to disable the cbo boxes on
form load and would I need to put code any where else?

Thank you for your time
 
W

Wayne Morgan

You would need code in the AfterUpdate or Click event of the check box and
in the subform's Current event to check the value when you move from record
to record. Without the code in the Current event, the combo boxes will
remain at their last state until you click the check box. You will need to
code for the check box being checked or unchecked.

Example code for each location:
Me.cmbCombo1.Enabled = Me.chkCheckbox
Me.cmbCombo2.Enabled = Me.chkCheckbox

Since the check box's value is True or False, this will simply pass the
value of the check box to the Enabled property of the combo boxes. If the
check box is checked (True) then the combo boxes will be enabled. If the
check box is unchecked (False) then they will be disabled. Set the Triple
State property of the check box to No and set the Default Value property of
the check box to False.

The above could be accomplished using and If..Then..Else statement also, but
this is shorter.
 

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