Tab to Next Control (1 Viewer)

Brian900

Registered User.
Local time
Today, 00:34
Joined
Oct 10, 2002
Messages
51
I want a Command Button on a form to move to the next Command Button. I basically want to do the same thing as the Tab button on my keyboard. However, I do not want to use the keyboard.
 

andyski101

Andy K
Local time
Yesterday, 19:34
Joined
Jun 13, 2005
Messages
61
In VBA program an OnCLick command that says Command1.SetFocus
 

Brian900

Registered User.
Local time
Today, 00:34
Joined
Oct 10, 2002
Messages
51
Thanks for the reply! I should have specified that I have a form with 11 Command Buttons. Ten are Command1, Command2....and so on. I want the 11th Command Button to tab through the 10 buttons.
 

andyski101

Andy K
Local time
Yesterday, 19:34
Joined
Jun 13, 2005
Messages
61
You can use the same command in a loop, I will edit this post with the code.

Code:
Public x As Integer
Option Compare Database

Private Sub Command0_Click()

If x < 10 Then
    x = x + 1
Else
    x = 1
End If
Me("Command" & x).SetFocus

End Sub
 
Last edited:

Brian900

Registered User.
Local time
Today, 00:34
Joined
Oct 10, 2002
Messages
51
That was absolutely it! I would have never figured that out. Thanks!
 

godofhell

Database Guru
Local time
Yesterday, 16:34
Joined
May 20, 2005
Messages
180
Good thing you kept a number at the end of the command button, otherwise this would not work unless a number was added at the end. Good job Andy.
 

Users who are viewing this thread

Top Bottom