423,680 Members | 2,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,680 IT Pros & Developers. It's quick & easy.

Enabling and disabling fields based on value of combo box.

P: 16
Hi,
I am working on a single form. I have two combo box named as-
1) CAST and 2) CATEGORY
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


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

PhilOfWalton
Expert 100+
P: 1,373
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

Phil
Jul 23 '18 #3

NeoPa
Expert Mod 15k+
P: 31,084
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

twinnyfo
Expert Mod 2.5K+
P: 2,666
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.