Q. Can I tab to a field from the main form, to a subform?

J

Jim Jones

Hi,


I have a form, with 2 subforms, I'd like to be able to use the tab key
to go directly to the first field (tab stop=0 in properties) in my
subform.

How do I do that, if you please?

Thanks,
Jim
 
W

Wayne Morgan

From the last control, try something similar to this in the KeyDown event of
that control.

If KeyCode = vbKeyTab Then
Me.NameOfSubformControl.SetFocus
Me.NameOfSubformControl.Form.txtField1.SetFocus
End If

To go from one subform to the other, the SetFocus should be modified to

Me.Parent.NameOfSubformControl.SetFocus
Me.Parent.NameOfSubformControl.Form.txtField1.SetFocus

Essentially, you have to go up to the main form, then back down to the other
subform.

NameOfSubformControl is the name of the control on the main form that holds
the subform, not the name of the subform. To get this name, open the main
form in design mode, open the Properties sheet, and click on the subform ONE
time. The properties sheet should show the name of the subform control. If
you click on the subform a second time, you'll be in the subform and the
properties sheet will show the name of the subform, not the control holding
it.
 
J

Jim Jones

From the last control, try something similar to this in the KeyDown event of
that control.

If KeyCode = vbKeyTab Then
Me.NameOfSubformControl.SetFocus
Me.NameOfSubformControl.Form.txtField1.SetFocus
End If

To go from one subform to the other, the SetFocus should be modified to

Me.Parent.NameOfSubformControl.SetFocus
Me.Parent.NameOfSubformControl.Form.txtField1.SetFocus

Essentially, you have to go up to the main form, then back down to the other
subform.

NameOfSubformControl is the name of the control on the main form that holds
the subform, not the name of the subform. To get this name, open the main
form in design mode, open the Properties sheet, and click on the subform ONE
time. The properties sheet should show the name of the subform control. If
you click on the subform a second time, you'll be in the subform and the
properties sheet will show the name of the subform, not the control holding
it.

That sounds like it should work. By the way, I seem to have lost the
ability to right-click on my subform, so I can click on properties
from the right-click menu. Of course I can click on view/properties to
get it. Any ideas on that little annoyance ? (how did I lost that
ability).

Thanks,
Jim
 
W

Wayne Morgan

There is a Properties icon on the toolbar and you can also get to it by
double clicking the control (prior to it being selected, if you double click
after it's selected, you just go into the control). How you lost the right
click? Check Tools|Startup..., is Allow Default Shortcut Menus checked?
 
J

Jim Jones

There is a Properties icon on the toolbar and you can also get to it by
double clicking the control (prior to it being selected, if you double click
after it's selected, you just go into the control). How you lost the right
click? Check Tools|Startup..., is Allow Default Shortcut Menus checked?

It is now, and thank you :)

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top