Move to Next Subform

N

Nylex

I used the Access 2003 Wizard and Created a form with subform and 2nd subform

When I enter the information on the main form it goes to the nest subform

This subform has 3 fields only - when I enter the data for these three
fields if goes to the next to the start for another entry - these is always
only one entry

After the record in subform two is entered and updated I want to go to the
first field in Subform Two

Cant see how to do it?
 
J

John Spencer

One way to do this is to use CONTROL + Tab to move out of the subform and onto
the next control in the main form.

Another is to add an invisible button to subform one. Set it to be the LAST
item in the tab order (view: Tab Order) and then put code in the Got Focus
event of the control to set the focus to the subform two control

The VBA (Untested) would look something like

Private Sub btnChangeFocus_GotFocus()
SetFocus Me.Parent.NameOfSubFormTwoControl
End sub

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
W

Wayne-I-M

Hi


You say
When I enter the information on the main form it goes to the nest subform

Is the 2nd subform nested ? - that is it is inside the 1st subform or is it
a 2nd subform on the main form ?

After the record in subform two is entered and updated I want to go to the
first field in Subform Two

Is there another way you can explain this - to make it more understandable.
Do you want o enter data into the 2nd subform and then go to the 1st tab
control on "that" subform

Do you want to go to the 1st record that is in the recordset of the 2nd
subform

etc
 
N

Nylex

I have a main form “Customerâ€
It has a subform “Propertyâ€
And subform “WorkOrderâ€
The Tab Order for the main form Is 6 fields and then “Property Subform†and
then “WorkOrder Subformâ€
When I fill in the 1st six fields it goes straight to the 2nd subform which
is linked to the Customer Form
The are only three fields on this form “Property Address†“Customer
Instructions†and “WorkNotes†– when these three fields are entered I want it
to go to the last subform not ask for another entry
I tried the Setfocus but did not work
 
N

Nylex

Did not Work - perhaps I did not explain properly
I have a main form “Customerâ€
It has a subform “Propertyâ€
And subform “WorkOrderâ€
The Tab Order for the main form Is 6 fields and then “Property Subform†and
then “WorkOrder Subformâ€
When I fill in the 1st six fields it goes straight to the 2nd subform which
is linked to the Customer Form
The are only three fields on this form “Property Address†“Customer
Instructions†and “WorkNotes†– when these three fields are entered I want it
to go to the last subform not ask for another entry
 
J

John Spencer

First, what did not work?

If you tried Control + Tab, did that move you to the WorkOrder subform if you
were in the Property subform?

My error!!! The VBA Code should look like
Me.Parent!WorkOrder.SetFocus

and if you want a SPECIFIC control in the WorkOrder subForm to get the focus,
you need two lines of code. One to set the focus to the WorkOrder subform and
a second one to set the focus to the specific control on the WorkOrder subform.

Me.Parent!WorkOrder.SetFocus

Me.Parent!WorkOrder.Form!NameOfControlOnSubForm.SetFocus



John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 

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