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!
JakeB52Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
DiveblueConnect With a Mentor Commented:
Jake, please let me know if you are having any difficulty with the solution I posted

DiveBlue
0
 
Richie_SimonettiIT OperationsCommented:
couldn't use gotfocus propety of tab to set the focus wherever you want?
0
 
DiveblueCommented:
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
JakeB52Author Commented:
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.

0
 
DiveblueCommented:
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
0
 
JakeB52Author Commented:
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.
0
 
DiveblueCommented:
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
0
 
DiveblueCommented:
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
0
 
JakeB52Author Commented:
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.
0
 
CleanupPingCommented:
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.
0
 
JakeB52Author Commented:
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.
0
All Courses

From novice to tech pro — start learning today.