Create Check box that controls visibility of a text box or combo b

H

Huskybydezign

I am a relatively new user to Access and am having trouble determining how to
make this work.

I have a form with several text boxes and combo boxes that are used to
select values to search in a query. I would like to create a check or toggle
box before each of the form controls that turns the control on or off. For
instance, if the check box is checked I want the user to be able to make a
selection from a combo box or input data into a text box and have the query
sorted per that value when the query is ran. If the check box is not checked
I would like the combo box/text box to remain uneditable, preferably in a
visible but not editable state.

Second part of this question:
Can you make a control visible but make it appear to be turned OFF or opaque
in color so that the user knows it cannot be edited until the check
box/toggle has been selected.

Lastly:
If you had several check boxes that contolled several combo/text boxes,
which were linked to their own fields. What criteria/code could you use to
have the unchecked boxes not show as columns in the query?

Any help would be appreciated
 
M

Mr. B

Use the After Update event of each of your check boxes and add VBA code like
the following to enable or disable a combo box:

Me.NameOfComboBox.Enabled = Me.NameOfCheckBox

In the code above, change the "NameOfComboBox" to the actual name of the
combo box you are wanting to control and change "NameOfCheckBox" to the
actual name of the check box that is going to control the combo box.

The code above could also be written:
If me.NameOfCheckBox = True then
Me.NameOfComboBox.enable = true
else
me.NameOfComboBox.enable = false
end if

By the way, FYI, the Enable property of controls makes them appear greyed
out and they do not function. Enabling them allows them to work again.

As a side note, I hope you have already provided custom naming for all of
your controls on your form. One thing that new users seem to have a problem
dealing with is that when Access creates controls, it just names them with
names like: combo0, combo1, ect. or Text0, Text1, etc. or Check0, Check1,
etc. I would suggest that you use a standard naming convention like: for a
combo box, use cboPurposeName where "Pruposename" is something meaningful.
For text boxes, use a prefix of txt and a meaningful name like txtMyVal,
check boxes would be chkSomename. I think you get the idea.

You will have the answer to your second question when you use the code above
in the After Update event of your check boxes.

For the last question: set the criteria for each columm that has a check
box (yes/No) field to: -1 or true

-----
HTH
Mr. B
http://www.askdoctoraccess.com/
Doctor Access Downloads Page:
http://www.askdoctoraccess.com/DownloadPage.htm
 

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