Setting focus

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Setting focus

Post by Pat »

When you set the focus to a control on a tab in a form, do you have to set the focus to the tab first?

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Setting focus

Post by HansV »

No, setting focus to a control on a tab page will automatically activate that tab page.
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Setting focus

Post by Pat »

I should have told more of the story, i get an error message on a setfocus command that i cannot set the focus to that control.
What are the conditions that a setfocus cannot work. I have a msgbox a few coomands after that setfocus command so i am not in VBA at the time it bombs.

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Setting focus

Post by HansV »

Does the error message mention why you can't set focus to it?
Is the control on a subform? If so, you must first set focus to the subform.
Is the control hidden at the moment that you want to set focus to it? If so, you must first make the control visible.
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Setting focus

Post by Pat »

I'll check that.