Tabbing out of subform

aimeepeter

Registered User.
Local time
Today, 04:52
Joined
May 12, 2008
Messages
11
Hi all,
I have written this code:

Private Sub TestStaff_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 9 Then
[Forms]![Shows Form]![Model#].SetFocus
End If
End Sub

to move from the end of a sub form to the next control on the main form. However when this is run, the focus is set to the 2nd next control on the form - it jumps over the next control [Model#] - weird.

Is there another way to write this code to move from the last field on the subform to the next field in sequence on the main form. Perhaps code to jump to a specific number in the tab order??

Cheers!
 
Since you still have a Tab key pending, guess what happens after you set the focus to the [Forms]![Shows Form]![Model#] control. ;) Just go ahead and eat the Tab key with:
Code:
If KeyCode = 9 Then
   [Forms]![Shows Form]![Model#].SetFocus
   KeyCode = 0
End If
 
Thanks RuralGuy - that did the trick!

In repsonse to the post from georgedwilkinson can you please explain how to use the tab order property to go from the subfrom back to the main form? I know how to set the tab order to move from the main to sub form and then to use Ctrl-Tab to move back to the main form, but how do you use the Tab Order Property to move back to the main form without the user needin to Ctrl-Tab.

Cheers!
 
I didn't understand that was what you were doing. The only way I've ever been able is by using datasheet view in my subform. It doesn't work with continuous.

I like Allan's response much better.
 

Users who are viewing this thread

Back
Top Bottom