Tab order from one subform to another

  • Thread starter Thread starter Winnie
  • Start date Start date
W

Winnie

I have two subforms built in one main form. The Tab order
only allows the tab go from the main form to the first
subform. when the tab finish the last stop of this first
subform it gose back to the first stop within this
subform instead of jumps to the first stop of next
subform. How do I make the tab jump from the last stop of
the first subform to the first stop of the second
subform? Should I do something on Expression for 'On Lost
Focus"? What VB codes I should put there? Please help.

Thanks in advance.

Winnie
 
Try setting the KeyPreview of the 1st subform to yes then in its KeyPress
event check for the tab key and that you are in the last control. If both
are true,

Me.Parent.SubformControl2.SetFocus

Note, you need to refer to the subform control that holds the subform, not
the name of the subform. Depending on how you added the subform to the main
form, they may both have the same name.
 
Hi Wayne,

Thanks for your kind reply. Some how my access only all
me to do

Me.LastControlNameOfTheSubform1.SetFocus

instead of

Me.Parent.SubformLastControl.SetFocus

the result I got is the tab stays at the last control of
subform1. It does not go back to the first control of
subform1 and not goes to the first control of subform2
either. What's wrong? Please advise.

Thanks,

Winnie
 
You need to set the focus to the 2nd subform control on the main (parent)
form. What is the name of the 2nd subform control on the main form? To get
this name, open the main form in design mode, open the Properties sheet,
click on the 2nd subform ONE time. The properties sheet should show the name
of the subform control. If you click on the subform a 2nd time you'll be in
the subform and the properties sheet will show the name of the subform, not
the control holding it.
 
Winnie

Assuming that main form is called "Winnie", subform 1 is "subform1" and the
last field in subform1 is [lastfield], and that the the second subform is
"SUBFORM2". These are for demonstration purposes only...

On the after update event on Subform1's [lastfield], code should look like
this...


Private Sub lastfield_AfterUpdate()

Forms![Winnie]![SUBFORM2].SetFocus

End Sub

Just replace Winnie, SUBFORM2 and [lastfield] with your form, subform and
field
names.

good luck and Merry Christmas
OzPete
 
Back
Top