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

Hiding a control in focus on click of another control in ms access 2007?

P: 99
I have a combobox and also a label on the same form.On click of the label, the combobox is to be made invisible.the problem is if the combobox is in focus and the label is clicked, it throws error saying that You can't hide a control which is in focus.I tried setting focus on the label itself when it is clicked but it didn't work.I also tried putting this code I found in one of the discussion forum
Expand|Select|Wrap|Line Numbers
  1. Sendkeys"{TAB}"
  2. DoEvents
it didn't work.
Also tried the following without any result
Expand|Select|Wrap|Line Numbers
  1. Screen.ActiveControl.Name=label1
Mar 2 '12 #1

✓ answered by TheSmileyCoder

You need a visible, enabled textbox (or combo/listbox) to move focus too, before hiding the combobox.

You cannot set focus to a label.

Share this Question
Share on Google+
5 Replies


100+
P: 759
Move the focus to the form itself before hide the combo box:
Expand|Select|Wrap|Line Numbers
  1. me.SetFocus
Mar 2 '12 #2

P: 99
Again: didn't work
same error
Mar 2 '12 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
You need a visible, enabled textbox (or combo/listbox) to move focus too, before hiding the combobox.

You cannot set focus to a label.
Mar 2 '12 #4

P: 99
Oh. Thanks.I found the similar answer on the site of "msdn" but I was skeptical about it as it wasn't mentioned explicitly.
Mar 2 '12 #5

NeoPa
Expert Mod 15k+
P: 31,308
HiGu:
I found the similar answer on the site of "msdn".
Indeed. It's always a good idea to search for an answer before posting a question. We're happy to answer your questions, but it will save you a lot of time and energy. Also, the more you do that the better able you are to find the best answers.
Mar 3 '12 #6

Post your reply

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