Solved

Need to tab from subform to main form form

Posted on 2004-10-26
214 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
Question by:cdmac2
    2 Comments
     
    LVL 58

    Accepted Solution

    by:
    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
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    913 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now