I've trapped the SHIFT+TAB and TAB keystrokes within the keydown event of a subform to behave appropriately (switch back and
forth between subform1 and subform2). However, my current problem is this:
Subform1 and Subform2 have 3 textbox controls each. If I am on control2 of subform2, and mouseclick to subform1, then tab to
control1, then control2, then control3 and tab again to appropriately switch to subform2, the focus is always set to the
previous active control of subform2 that I clicked out of. This only happens if I mousclick out of subform2. Tabbing works
I would like that focus to ALWAYS go back to control1 of subform2 when I click out of subform2 to subform1 and tab back to
subform2. Confusing enough? I hope not.
I'm fairly proud of myself for figuring out a way to trap these keystrokes to move between the two subforms properly, rather
than using the OnExit event, so please no floggings for doing this the complicated way. I have specific reasons for why I
need this to behave accordingly. Mostly being that I don't want people to be able to go to control2 of subform2 if control1
of subform1 has nothing in it.
If any advice is available to get the focus to reset to control1 after mousclicking out of subform2 and tabbing back to
subform2, I would be very grateful.
Here is my keystroke trap code from the OnKeyDown event of Subform1:
Private Sub Form_KeyDown(Keycode As Integer, shift As Integer)
If (Keycode = vbKeyTab) And ((shift And acShiftMask) > 0) Then
If Screen.ActiveControl.Name = Me.Vest_New_PIDtxtbox.Name Then
ElseIf Screen.ActiveControl.Name = Me.Vest_New_Due_Datetxtbox.Name Then
If (Keycode = vbKeyTab) And ((shift And acShiftMask) = 0) Then
If Screen.ActiveControl.Name = Me.Vest_New_Due_Datetxtbox.Name Then
Keycode = 0