Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Need to tab from subform to main form form

Posted on 2004-10-26
2
Medium Priority
?
287 Views
Last Modified: 2009-07-29
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
Comment
Question by:cdmac2
2 Comments
 
LVL 58

Accepted Solution

by:
harfang earned 1000 total points
ID: 12418740
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
 
LVL 1

Author Comment

by:cdmac2
ID: 12430217
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question