go to control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a tabbed form. From one tab i want to move to another tab where i have
a sub form which is also tabbed. I need to go to one of these tabs to do a
find record

I have tried
Dim ctl As Control
Set ctl = Forms![systemForm]![purchaseOrderSubForm]![ordersForm]
DoCmd.GoToControl ctl.name

but get the message - there is no field [ordersForm] in the current record

If I just use
Set ctl = Forms![systemForm]![purchaseOrderSubForm]
it is fine but I need to make sure that the correct tab is showing

Any suggestions please
 
judith said:
I have a tabbed form. From one tab i want to move to another tab where i have
a sub form which is also tabbed. I need to go to one of these tabs to do a
find record

I have tried
Dim ctl As Control
Set ctl = Forms![systemForm]![purchaseOrderSubForm]![ordersForm]
DoCmd.GoToControl ctl.name

but get the message - there is no field [ordersForm] in the current record

If I just use
Set ctl = Forms![systemForm]![purchaseOrderSubForm]
it is fine but I need to make sure that the correct tab is showing


You need to go through the Form object to get to a control
on the subform. I don't like the DoCmd things when there's
another way, in this case the SetFocus method.

Another issue could be that you should set the focus to the
subform control before you go to a control within the
subform. Try this:

Forms![systemForm]![purchaseOrderSubForm].SetFocus
Forms![systemForm]![purchaseOrderSubForm].FORM![ordersForm].SetFocus

If this code is in the main form's module, then the
references can be shortened to:

Me![purchaseOrderSubForm].SetFocus
Me![purchaseOrderSubForm].FORM![ordersForm].SetFocus
 
Back
Top