Set Focus to a Field on Page of Tab Control (1 Viewer)

PSSMargaret

Registered User.
Local time
Today, 01:24
Joined
Jul 23, 2016
Messages
74
Hello all,

I have exhausted my searches for help on this matter. I have a main form, a tab control with four subforms on the tab control.

I would like the focus to move from the last field on the main form to the first field on the first page of the tab control. I have tried using the OnKeyDown event with the code below and it doesn't work. I have to hit the tab key twice to get it to the first field.

Code:
Me.sfrmMaterial.SetFocus

I have tried using the AfterUpdate event on the form too and it doesn't work. You still have to tab twice to get to the field.

Code:
TabForm.Pages(0) = "Material"

If you set the Tab Stop to "No" for the Tab Control, the focus doesn't move to the Tab Control at all.

Any help in the would be greatly appreciated.

If I have missed any pertinent posts regarding this subject, please direct me to them.

Margaret
 

Ranman256

Well-known member
Local time
Today, 04:24
Joined
Apr 9, 2015
Messages
4,337
im guessing the tabs form is a sub form?
if it is, use the Builder to get the correct path of the textbox....
its prob like:
me!sub.setfocus
me!sub!form!txtBox.setfocus
 

PSSMargaret

Registered User.
Local time
Today, 01:24
Joined
Jul 23, 2016
Messages
74
There is a tab control that you can add pages to (I have four pages) and then each page has a subform on it. It seems that no matter what code I use, it still tab stops on the Tab Control so you have to tab twice to get to the first page. When I use the Builder to identify the name of the control and then input that into the VBA code, it says it doesn't recognize the name.
 

PSSMargaret

Registered User.
Local time
Today, 01:24
Joined
Jul 23, 2016
Messages
74
Thanks for your response Ranman256

You can disregard. I found the solution on another site. Listed below.

Me.NameOfSubform.SetFocus
Me.NameOfSubforml.Form!NameOfControl.SetFocus

Boy that was a pain. I didn't realize it needed one line of code to set the focus to the subform and then another line of code to get you to the field control.

Thanks again. Margaret
 

Users who are viewing this thread

Top Bottom