Tabbed Form / Subform Cursor Positioning.

G

Guest

I have a tabbed page form with for pages on it. The first three allow entry
of data to one table (a primary table) and the last page holds a subform that
was added via Subform wizards (a pre-existing form added as subform). The
subform updates a secondary table to the primary table. Kind of like Order
table and product table.

Anyway, the first three pages of the tabbed form scroll or roll
automatically to the next field by using a command button to "SET CONTROL" to
the next tabbed page, next field location.

Problem is when I try to automatically scroll to the next field position
(the first field on the sub form) it does not work. I get the error that the
control is not on the current form or current table. How do I "SET CONTROL"
to be directed to the subform. I hav even tried to set focus to the first
field on the subform via code, but that doesn't compile correctly either.

the primary form name is FR_CR_E. The sub form name is FR_ADD_OTHERS_E

The first field I would like to position to on the Subform is named
Vehicle_Cde.

Can anyone assist in this issue. I have found in Microsoft Access Help that
you supposedly can not use SET.CONTROL on subforms from forms, that you have
to use SetFocus, but I can not seem to get the code correct. I've tried....

Private Sub Command396_Click()
[Form].[SFr_Add_Others_E].[VEHICLE_CDE].SetFocus
End Sub

and it gives errors. Any clues..??

Thanks in advance
 
G

Guest

Problem is resolved. To all with this type of main form/subform focus
control issues take note:

GoToControl does not work on a form/subform issue where the subform is not
active form on a TABBED Page form.

Instead, use...... SetFocus Sample code below works well with command
button to focus control to subform screen and a specific field. This works
when the command button is on a tabbed page of a main form, and the subform
is an existing form added to a tabbed page of the main form via the subform
wizard.

* The name of the subform used in this example is: sbfFr_Add_Others_E
* the name of the field that I wanted to focus to is named: VEHICLE_CDE
* two lines of code are needed to complete the function from a sub area,
they are:

Private Sub Command396_Click()
Me.sbfFr_Add_Others_E.SetFocus
Me.sbfFr_Add_Others_E.Form!VEHICLE_CDE.SetFocus
End Sub

Hope this helps others with this issue.

Thanks,
 
G

Guest

Well folks the code below works to take you from one page of the tabbed form
to the other but it gives an error if you are currently trying to add data to
it, so I'm sorry for misleading anyone.

Private Sub Command396_Click()

Me!sbfFr_CR_E.SetFocus
Me!sbfFr_CR_E.Form!VEHICLE_CDE.SetFocus

End Sub

Again, I as for help. Does anyone here have any suggestions. My main form
name is
Fr_CR_E it is a 4 page tabbed form. Page 0, 1 & 2 update primary table,
page 3 is a Subform added to the tabbed form. The name of the subform is
sbfFR_CR_E. The subform is linked to the main form via primary key controls
for table 1 and table 2. These carry over to subform fine. The code above,
when executed from a command button works fine to take you to the subform,
but when you try to enter data to the form, it fails with the following

Run-time error '2110'
Microsoft Office Access can't move the focus to the control sbfFr_CR_E

Can anyone advise !


Robert Nusz @ DPS said:
Problem is resolved. To all with this type of main form/subform focus
control issues take note:

GoToControl does not work on a form/subform issue where the subform is not
active form on a TABBED Page form.

Instead, use...... SetFocus Sample code below works well with command
button to focus control to subform screen and a specific field. This works
when the command button is on a tabbed page of a main form, and the subform
is an existing form added to a tabbed page of the main form via the subform
wizard.

* The name of the subform used in this example is: sbfFr_Add_Others_E
* the name of the field that I wanted to focus to is named: VEHICLE_CDE
* two lines of code are needed to complete the function from a sub area,
they are:

Private Sub Command396_Click()
Me.sbfFr_Add_Others_E.SetFocus
Me.sbfFr_Add_Others_E.Form!VEHICLE_CDE.SetFocus
End Sub

Hope this helps others with this issue.

Thanks,


Robert Nusz @ DPS said:
I have a tabbed page form with for pages on it. The first three allow entry
of data to one table (a primary table) and the last page holds a subform that
was added via Subform wizards (a pre-existing form added as subform). The
subform updates a secondary table to the primary table. Kind of like Order
table and product table.

Anyway, the first three pages of the tabbed form scroll or roll
automatically to the next field by using a command button to "SET CONTROL" to
the next tabbed page, next field location.

Problem is when I try to automatically scroll to the next field position
(the first field on the sub form) it does not work. I get the error that the
control is not on the current form or current table. How do I "SET CONTROL"
to be directed to the subform. I hav even tried to set focus to the first
field on the subform via code, but that doesn't compile correctly either.

the primary form name is FR_CR_E. The sub form name is FR_ADD_OTHERS_E

The first field I would like to position to on the Subform is named
Vehicle_Cde.

Can anyone assist in this issue. I have found in Microsoft Access Help that
you supposedly can not use SET.CONTROL on subforms from forms, that you have
to use SetFocus, but I can not seem to get the code correct. I've tried....

Private Sub Command396_Click()
[Form].[SFr_Add_Others_E].[VEHICLE_CDE].SetFocus
End Sub

and it gives errors. Any clues..??

Thanks in advance
 

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