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

Enabling and disabling fields based on value of combo box.

P: 16
I am working on a single form. I have two combo box named as-
Combo box CAST has options like - Brahmin, Jat, Gurjar, Bunkar etc.
And Combo box CATEGORY has option like - GEN, OBC, ST, SC etc.
I want to write a vba code in after update event for combo box CAST, so if I choose option like Jat or Gurjar, the Combo box CATEGORY should be enabled. And, if I choose option like Bunkar or Brahmin, the Combo box CATEGORY should be disabled.
Please help.
Jul 23 '18 #1
Share this Question
Share on Google+
4 Replies

Expert Mod 2.5K+
P: 3,284
Expand|Select|Wrap|Line Numbers
  1. Me.CATEGORY.Enabled = ((Me.CAST = "jat") _
  2.                     OR (Me.CAST = "Gurjar"))
Hope this hepps!
Jul 23 '18 #2

Expert 100+
P: 1,430
Sorry, but that's not very elegant, Twinny.

Add a Yes/No field the the Cast Table and enable or disable the CATEGORY Combo depending on the value of that field.

That way you are not limited to the number of casts

Jul 23 '18 #3

Expert Mod 15k+
P: 31,489
While Twinny's answer is a correct and direct answer to the question as posed, I have to agree with Phil that his suggestion is more flexible and continues to work well even when the requirements change slightly. His solution does have that element of elegance ;-)
Jul 23 '18 #4

Expert Mod 2.5K+
P: 3,284
Elegance: yes; flexibility: not quite so much.


Indeed, Phil has a better solution.
Jul 23 '18 #5

Post your reply

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