?
Solved

Please Help! Tabbing does not work properly using the SSTab control.

Posted on 2003-03-11
11
Medium Priority
?
223 Views
Last Modified: 2010-04-07
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!
0
Comment
Question by:JakeB52
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8113339
couldn't use gotfocus propety of tab to set the focus wherever you want?
0
 
LVL 3

Expert Comment

by:Diveblue
ID: 8113849
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
 

Author Comment

by:JakeB52
ID: 8114146
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:Diveblue
ID: 8115119
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
 

Author Comment

by:JakeB52
ID: 8119669
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
 
LVL 3

Expert Comment

by:Diveblue
ID: 8121066
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
 
LVL 3

Expert Comment

by:Diveblue
ID: 8121075
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
 

Author Comment

by:JakeB52
ID: 8123529
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
 

Expert Comment

by:CleanupPing
ID: 9056434
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
 
LVL 3

Accepted Solution

by:
Diveblue earned 1100 total points
ID: 9090197
Jake, please let me know if you are having any difficulty with the solution I posted

DiveBlue
0
 

Author Comment

by:JakeB52
ID: 9090321
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question