Tab movement

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

Hi all

Is it possible to program the tab key to return to the
main form when it is inside a subform. I have a the tab
set up that it goes to the sub form, but I can't jump back
out to the main form when the tab key is in the subform.
Is it possible to progam a tab key to return to the main
form once it is in a subform??

Thanks for your help...

mike
 
Set the subform's KeyPreview property to True. That will cause all key
strokes to be processed by the form's KeyDown event before the control's
events.

Then add code to the subform's KeyDown event to trap for the tab key and set
focus back to the parent form.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

' Trap tab key
If KeyCode = vbKeyTab Then
Me.Parent!NextControlInTabOrder.SetFocus
End If

End Sub

The only problem is that trapping the keystroke will not prevent the tab
action from occurring in the subform. So the next field in the subform will
be highlighted and a Current event might fire in the subform. If this is not
a problem, you're done.

HTH.

- Assaf
 
mike said:
Is it possible to program the tab key to return to the
main form when it is inside a subform. I have a the tab
set up that it goes to the sub form, but I can't jump back
out to the main form when the tab key is in the subform.
Is it possible to progam a tab key to return to the main
form once it is in a subform??

Ctrl + Tab will already do that.
 
Back
Top