JakeB52
asked on
Please Help! Tabbing does not work properly using the SSTab control.
This problem has me stumped.
I have a form with a SSTab control on it. There are about 7 tabs on the control, each of which contains several textboxes setup as an array (ie txtData(0)). The form is designed so that each tab is considered a "step" in the completion process. Once the user comes to the last textbox (txtData(13)) on the first tab, I want the focus to be set to the txtData(14) on the next tab.
Right now, I reach the end of the first tab, press the tab key and it seems like nothing is happening. I do believe the the next textbox is receiving focus in the background but the tab does not switch so I can see it.
The solution has to be done through code (no keystrokes) so that tabbing from one step to the next appears nice and smooth for the user.
Any help on this would be greatly appreciated!
I have a form with a SSTab control on it. There are about 7 tabs on the control, each of which contains several textboxes setup as an array (ie txtData(0)). The form is designed so that each tab is considered a "step" in the completion process. Once the user comes to the last textbox (txtData(13)) on the first tab, I want the focus to be set to the txtData(14) on the next tab.
Right now, I reach the end of the first tab, press the tab key and it seems like nothing is happening. I do believe the the next textbox is receiving focus in the background but the tab does not switch so I can see it.
The solution has to be done through code (no keystrokes) so that tabbing from one step to the next appears nice and smooth for the user.
Any help on this would be greatly appreciated!
couldn't use gotfocus propety of tab to set the focus wherever you want?
in your textbox validate event...
Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
Select Case Index
Case 1 'last textbox on tab 0
Me.SSTab1.Tab = 1
Text1(2).SetFocus 'first text control on tab 1
Case 4 'last textbox on tab 1
Me.SSTab1.Tab = 2
Text1(Index + 1).SetFocus 'first text control on tab 2
End Select
End Sub
Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
Select Case Index
Case 1 'last textbox on tab 0
Me.SSTab1.Tab = 1
Text1(2).SetFocus 'first text control on tab 1
Case 4 'last textbox on tab 1
Me.SSTab1.Tab = 2
Text1(Index + 1).SetFocus 'first text control on tab 2
End Select
End Sub
ASKER
Diveblue,
Your code works fine but I was wondering, what if the user wants to go back to the privious tab using the <shift tab> key combination? I should have mentioned this in the original post but I forgot to think backwards.
Your code works fine but I was wondering, what if the user wants to go back to the privious tab using the <shift tab> key combination? I should have mentioned this in the original post but I forgot to think backwards.
Here you go.... extra points for this? :)
Scott
Place the following in your declarations(general) section of your form
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const VK_SHIFT = &H10
Private Const VK_TAB = &H9
amend my first sample as follows
Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
Select Case Index
Case 1 'last textbox on tab 0
if GetKeyState(VK_TAB)= 1 then
Me.SSTab1.Tab = 1
Text1(2).SetFocus 'first text control on tab 1
end if
case 3 '1st textbox on tab 1
if GetKeyState(VK_TAB)= 1 and _
GetKeyState(VK_SHIFT)= 1 then
Me.SSTab1.Tab = 0
Text1(1).SetFocus '1st text control on tab 0
end if
Case 4 'last textbox on tab 1
if GetKeyState(VK_TAB)= 1 then
Me.SSTab1.Tab = 2
Text1(5).SetFocus '1st text control on tab 2
end if
End Select
End Sub
Scott
Place the following in your declarations(general) section of your form
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const VK_SHIFT = &H10
Private Const VK_TAB = &H9
amend my first sample as follows
Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
Select Case Index
Case 1 'last textbox on tab 0
if GetKeyState(VK_TAB)= 1 then
Me.SSTab1.Tab = 1
Text1(2).SetFocus 'first text control on tab 1
end if
case 3 '1st textbox on tab 1
if GetKeyState(VK_TAB)= 1 and _
GetKeyState(VK_SHIFT)= 1 then
Me.SSTab1.Tab = 0
Text1(1).SetFocus '1st text control on tab 0
end if
Case 4 'last textbox on tab 1
if GetKeyState(VK_TAB)= 1 then
Me.SSTab1.Tab = 2
Text1(5).SetFocus '1st text control on tab 2
end if
End Select
End Sub
ASKER
DiveBlue,
It makes sense but my code doesn't seem to recognize the "if" condition containing the GetKeyState function.
The following was placed in the general declaration (under Option Explicit) of the form but nothing is happening. Do I need any additional references or anything?
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const VK_SHIFT = &H10
Private Const VK_TAB = &H9
BTW I've increased the points since the question is beyond the scope of what was originally asked.
It makes sense but my code doesn't seem to recognize the "if" condition containing the GetKeyState function.
The following was placed in the general declaration (under Option Explicit) of the form but nothing is happening. Do I need any additional references or anything?
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const VK_SHIFT = &H10
Private Const VK_TAB = &H9
BTW I've increased the points since the question is beyond the scope of what was originally asked.
that's what I get for not testing my own code! try this...
I noticed that the setfocus doesn't seem to work. I'm not sure about that part yet.
Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
Select Case Index
Case 1 'last textbox on tab 0
' MsgBox GetKeyState(VK_TAB)
If GetKeyState(VK_TAB) <> 0 Then
Me.SSTab1.Tab = 1
Text1(2).SetFocus 'first text control on tab 1
End If
Case 2 '1st textbox on tab 1
Debug.Print GetKeyState(VK_TAB), GetKeyState(VK_SHIFT)
If GetKeyState(VK_TAB) <> 0 And _
GetKeyState(VK_SHIFT) <> 0 Then
Me.SSTab1.Tab = 0
Text1(0).SetFocus '1st text control on tab 0
End If
Case 3 'last textbox on tab 1
If GetKeyState(VK_SHIFT) = 0 Then
Me.SSTab1.Tab = 2
Text1(3).SetFocus '1st text control on tab 2
End If
End Select
End Sub
I noticed that the setfocus doesn't seem to work. I'm not sure about that part yet.
Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
Select Case Index
Case 1 'last textbox on tab 0
' MsgBox GetKeyState(VK_TAB)
If GetKeyState(VK_TAB) <> 0 Then
Me.SSTab1.Tab = 1
Text1(2).SetFocus 'first text control on tab 1
End If
Case 2 '1st textbox on tab 1
Debug.Print GetKeyState(VK_TAB), GetKeyState(VK_SHIFT)
If GetKeyState(VK_TAB) <> 0 And _
GetKeyState(VK_SHIFT) <> 0 Then
Me.SSTab1.Tab = 0
Text1(0).SetFocus '1st text control on tab 0
End If
Case 3 'last textbox on tab 1
If GetKeyState(VK_SHIFT) = 0 Then
Me.SSTab1.Tab = 2
Text1(3).SetFocus '1st text control on tab 2
End If
End Select
End Sub
that's what I get for not testing my own code! try this...
I noticed that the setfocus doesn't seem to work. I'm not sure about that part yet.
Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
Select Case Index
Case 1 'last textbox on tab 0
' MsgBox GetKeyState(VK_TAB)
If GetKeyState(VK_TAB) <> 0 Then
Me.SSTab1.Tab = 1
Text1(2).SetFocus 'first text control on tab 1
End If
Case 2 '1st textbox on tab 1
Debug.Print GetKeyState(VK_TAB), GetKeyState(VK_SHIFT)
If GetKeyState(VK_TAB) <> 0 And _
GetKeyState(VK_SHIFT) <> 0 Then
Me.SSTab1.Tab = 0
Text1(0).SetFocus '1st text control on tab 0
End If
Case 3 'last textbox on tab 1
If GetKeyState(VK_SHIFT) = 0 Then
Me.SSTab1.Tab = 2
Text1(3).SetFocus '1st text control on tab 2
End If
End Select
End Sub
I noticed that the setfocus doesn't seem to work. I'm not sure about that part yet.
Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
Select Case Index
Case 1 'last textbox on tab 0
' MsgBox GetKeyState(VK_TAB)
If GetKeyState(VK_TAB) <> 0 Then
Me.SSTab1.Tab = 1
Text1(2).SetFocus 'first text control on tab 1
End If
Case 2 '1st textbox on tab 1
Debug.Print GetKeyState(VK_TAB), GetKeyState(VK_SHIFT)
If GetKeyState(VK_TAB) <> 0 And _
GetKeyState(VK_SHIFT) <> 0 Then
Me.SSTab1.Tab = 0
Text1(0).SetFocus '1st text control on tab 0
End If
Case 3 'last textbox on tab 1
If GetKeyState(VK_SHIFT) = 0 Then
Me.SSTab1.Tab = 2
Text1(3).SetFocus '1st text control on tab 2
End If
End Select
End Sub
ASKER
I'm still having a few problems (getting closer though)with the code but I'll take another look at it tomorrow. If you think of anything else in the meantime, let me know.
Thanks for your patience on this one.
Thanks for your patience on this one.
JakeB52:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry Diveblue for the delay.
Your suggestions did give me some excellent ideas and the problem was eventually solved. Without your suggestions, I would have been lost.
Thank you.
Your suggestions did give me some excellent ideas and the problem was eventually solved. Without your suggestions, I would have been lost.
Thank you.