Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

Need to tab from subform to main form form

I have a subform "frmMaster" that I place as a subform in many different forms... I will use "frmArt" as the main form in this example.

The user first tabs through the fields on "frmMaster" then should move onto tabbing through "frmArt".  The problem is that once I hit the last field on the "frmMaster", it just cycles back to the first field of "frmMaster" instead of tabbing on to "frmArt".

I have tried the following code set to the Exit property of the last field in "frmMaster", but came up with errors each time

DoCmd.GoToControl "frmArt"
Run-time error 2109:  There is no filed named 'frmArt' in the current record.

DoCmd.GoToControl Form_Art
Run-time error 2109:  There is no filed named 'Form_frmSpecSofa' in the current record.

DoCmd.GoToControl Me.Parent
Run-time error 2498:  An expression you entered is the wrong data type for one of the arguments.

Thanks!
Mike

0
cdmac2
Asked:
cdmac2
1 Solution
 
harfangCommented:
The method you want to use is .SetFocus

Choose the "next" field in frmArt, for example txtFooBar. Create an almost invisible control on frmMaster (transparent, same back color, width 0...) say txtJump, being the last in the tab order. Create the OnEnter handler:

Sub txtJump_Enter()
   Me.Parent!txtFooBar.SetFocus
End Sub

This implies that all potential main forms have a "txtFooBar" control...
To be a little more fancy, make sure that the subform frmMaster is always in a subform *control* called subMaster. This way, you can use the Tag of that control to hold the name of the next control for that particular main form.

Sub txtJump_Enter()
   Me.Parent(Me.Parent!subMaster.Tag).SetFocus
End Sub

On the form frmArt, subMaster.Tag will be "txtFooBar", but on frmAnother, it might be "cboSelection"...

Finally, I prefer to create a txtJump control specially and use _Enter because there are many ways to exit a control, even if it is the last (shift+tab, click on another control, etc.).

Incidentally, in your attempts, you used DoCmd.Goto*Control*, but you never tried with a control name!

Hope this helps
0
 
cdmac2Author Commented:
Wonderful!  Thank you, it took me a little while, but I figure out how to do that submaster.Tab thing that you were talking about... Works like a Charm.

Thanks!

Mike
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now