Tab Order from Form Header to Detail

Full_Williams

Registered User.
Local time
Today, 12:15
Joined
Jul 2, 2002
Messages
88
Hi,

I have a form that has controls in the header and detail. Is there a way that I can combine their tab orders so they are not separate? Right now I can only tab in the Header. If I set the focus on current to the first tab in the detail I am not able to tab up to the header. Any help would be appreciated.

Thanks,
Full Williams
 
You could put a focus call in your onExit of the last control in your header and detail.

sub Text5_Exit()
me.Text6.SetFocus
End Sub

Set Text10_Exit()
me.Text1.SetFocus
End Sub

*****
This examples assumes you have text boxes 1 through five in your header and text boxes 6 through 10 in your Detail.
*****
 
Drevlin,

Thanks. That works fine except for when I try to go back up the tab order using shift-tab. Anyway to for the code to read that I've pressed shift and want to backwards in the tab order?

Thanks,
Full Williams
 
Ok, the scenerio is the same. You have five text boxes in your Header labelled text1, text2... text5. You have 5 text boxes in your Detail: text6, text7... text10.

This would be your code to tab either direction:

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
'If your in Text1 and you tab forward.
If Shift = 0 And KeyCode = 9 Then
Me.Text2.SetFocus
End If

'If your in Text1 and you tab Backwords -- Shift+Tab
If Shift = 1 And KeyCode = 9 Then
Me.Text10.SetFocus
End If
End Sub

Private Sub Text10_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = 0 And KeyCode = 9 Then
Me.Text1.SetFocus
End If
If Shift = 1 And KeyCode = 9 Then
Me.Text9.SetFocus
End If
End Sub

Private Sub Text5_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = 0 And KeyCode = 9 Then
Me.Text6.SetFocus
End If
If Shift = 1 And KeyCode = 9 Then
Me.Text4.SetFocus
End If

End Sub

Private Sub Text6_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = 0 And KeyCode = 9 Then
Me.Text7.SetFocus
End If
If Shift = 1 And KeyCode = 9 Then
Me.Text5.SetFocus
End If
End Sub


Enjoy.
 
Drevlin ,
Thanks, that works great! Is there a way to use the Alt key too?

For example:

Private Sub Text1_KeyDown(KeyCode As Integer, Alt As Integer)
'If your in Text1 and you press -- Alt+Tab
If Alt= 1 And KeyCode = 9 Then
Me.Text5.SetFocus
End If
End Sub

My form is continuous so I might have more than one Text6 field.

Thanks,
Full Williams
 
I wouldn't do what your asking because Alt+Tab is the key combination that switches between programs in Windows and it would be complicated to override this function.

If it weren't for this fact it would be possible to do what your asking but not quite as you have it.

The Procedure for the KeyPress receives 2 values. The number of the key that's pressed and whether one of the side keys is pressed (shift = 1, cntrl = 2, alt = 4 [I have no idea which key is 3]).

You can name the values anything you want i.e.:

Private Sub text1_KeyPress(Ogres as Integer, Buffalo as Integer)

but they will always return the same information.

So since you can't use Alt + Tab you could try using Ctl + Tab.

Private Sub Text1_KeyDown(Keycode As Integer, Shift As Integer)
'Just Tab
If Shift = 0 And Keycode = 9 Then
Me.Text2.SetFocus
End If
'Shift + Tab
If Shift = 1 And Keycode = 9 Then
Me.Text10.SetFocus
End If
'Ctl + Tab
If Shift = 2 And Keycode = 9 Then
Me.Text7.SetFocus
End If

End Sub
 
Drevlin,

Awesome! Yeah, Ctl-Tab is fine. Good advice on not using Alt-Tab.

Thanks for your help,
Full Williams
 

Users who are viewing this thread

Back
Top Bottom