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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Navigation

Status
Not open for further replies.

PADFOR

Programmer
Feb 5, 2001
25
GB
How do I navigate from the sub-form back to the main forms using keyboard. When the focus is in a sub-form, it remains there.

How do I capture a key (TAB) (keyboard event) when I am leaving the sub-form to put me back into the main form? Can this be done using Macros?

Cheers

PADFOR
 
Hi Padfor,
Your subform properties "Events" tab: towards the bottom find "Key Preview" and turn it on (Yes).

In the Key Down event (event procedure) then "..." to visual basic, something like this:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim ctl As Control
Set ctl = Me.ActiveControl
If Me.ActiveControl.Name = "NameOfYourFieldHere" Then
If KeyCode = vbKeyTab Then
Me.Parent.SetFocus
Me.Parent.NameOfSomeFieldOnYourMainForm.SetFocus
End If
End If
End Sub

Will do. :) Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top