By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,455 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,455 IT Pros & Developers. It's quick & easy.

Enabling / Disabling Controls by Checkbox

P: 1
I am creating a form in Access, in the form there is a checkbox and some fields. I want to set the checkbox so, that if the user clicks on it, the fields should be enabled, if the checkbox has not been clicked, thann the fields remain disabled.

Could you please help me to write the VBA-code for this procedure?

Thank you!!

Jan 28 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,072
Best to use the .tag property of the formcontrols.
atJust mark the fields the should be enabled with a "E" in the .tag property (under the Other tab of the property popupform).

Now you can use this code in the OnOpen event of the form and the AfterUpdate of the checkbox:
Expand|Select|Wrap|Line Numbers
  2. dim ctl as control
  4. for each ctl in me.controls
  5.     if ctl.tag = "E" then
  6.       if me.checkboxfield then
  7.          ctl.enabled = true
  8.      else
  9.          ctl.enabled = false
  10.      endif
  11.    endif
  12. next
Getting the idea ?

Jan 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.