Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving from header to subform in detail 1

Status
Not open for further replies.

BSman

Programmer
Apr 16, 2002
718
US
When users enter data in the last field in the header of a form and press <Enter> or <Tab>, I'd like the cursor to move to the first field in the (continuous) subform, which is in the detail part of the form (and is the only control in the detail area). However, the cursor moves from the last control in the header to the first control in the header. Any suggestions for how to get it to work they way I'd like?

Bob
 
I think you must use an event, for example:

Code:
Private Sub LastHeaderTextboxName_Exit(Cancel As Integer)
Me.FirstDetailTextboxName.SetFocus
End Sub
 
Make a text box in your header call it "txtBxMove". This should be the last in the headers tab order. If you set the background to the form background it will basically be invisible, or make it as small as possible. You can not set the property to invisible.

Private Sub txtBxMove_Enter()
Me.FirstDetailTextboxName.SetFocus
End Sub

Remous, suggestion works but it will move to the detail section when you might tab backwards or click into another header textbox.
 
Thanks, MajP, for the suggestion about adding a control that's "sort of" visible. It works well whether the user moves forward with the Enter or the Tab key, but avoids any problems with trying to move from the last visible control that the user would see.

Bob
 
How are ya BSman . . .

Couldn't resist although resolution has been accomplished.

In the [blue]On Key Down[/blue] event of the last field in the header, copy/paste the following:
Code:
[blue]   If Shift = 0 And (KeyCode = 9 Or KeyCode = 13) Then
      [purple][B][I]subFormname[/I][/B][/purple].SetFocus
      [[purple][B][I]subFormname[/I][/B][/purple]].Form![purple][B][I]FirstSubformTextboxName[/I][/B][/purple].SetFocus
   End If[/blue]
Note: no additional textbox required here!

Also, you can do the reverse by detecting [blue]Shift Tab/Enter[/blue] in the [blue]On Key Down[/blue] event of the [purple]FirstSubformTextboxName[/purple].

Note: you'll have to disable previous code to see the effect.

[blue]Your Thoughts? . . .[/blue]


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Aceman1,

Sounds like a good alternate to the semi-visible text box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top