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

hide/show a combobox

P: 1
hi guyz
I've a list for combobox1:"Kine","Aquaquam","Mahlet" and "Testament" as well for that of combobox2: "Old Testament" and "New Testament".
So Combobox2 should be displayed in the form-view if value of Combobox1 is "Testament".
I've attempt the following code:
Expand|Select|Wrap|Line Numbers
  1. private sub bombobox1_BeforUpdate()
  2. if combobox1 = "Testament" then
  3.   combobox2.visible = false
  4. else
  5.   combobox2.visible = true
  6. endif
  7. me.requery
  8. me.refresh
  9. me.repaint
  10. end sub
Thank you in advance
Jun 29 '12 #1
Share this Question
Share on Google+
2 Replies


Seth Schrock
Expert 2.5K+
P: 2,937
What happens? Do you get an error message, or does combobox2 just remain visible?

It would probably work better to put your code in the combobox1 After_Update event instead of the before_update event. You also shouldn't need the Me.requery, me.refresh, and me.repaint commands.

(don't forget to use the code tags when posting code. Use the button that says <code/> to enter your code so that viewing is easier.)
Jun 29 '12 #2

100+
P: 759
Your logic do not fit your implementation.
You say:
So Combobox2 should be displayed in the form-view if value of Combobox1 is "Testament".
But the implementation is:
Expand|Select|Wrap|Line Numbers
  1. if combobox1 = "Testament" then
  2.   combobox2.visible = false
  3. else
  4.   combobox2.visible = true
  5. endif
So, if combobox1 = "Testament" then combobox2 will not be visible. Isn't it ?

Replace your lines 3 to 6 with this one:
Expand|Select|Wrap|Line Numbers
  1. combobox2.visible = (combobox1 = "Testament")
Jun 30 '12 #3

Post your reply

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