Tab to Next Control

Brian900

Registered User.
Local time
Today, 21:46
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.
 
In VBA program an OnCLick command that says Command1.SetFocus
 
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.
 
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:
That was absolutely it! I would have never figured that out. Thanks!
 
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

Back
Top Bottom