Comm. Button for =Keyboard Tab

I

Indu

Dear All,
I am using one main form and sub form. When entering data user need to click
the button and go forward. It meen I need to create a command button to do
what is “Keyboard Tab†doing. Macro or Coding
Any help would be appreciated.
Indu
 
F

freakazeud

Hi,
since you should avoid sendkeys I quickly put together some sample code
which might work for you. Most likely you will know how many textbox controls
you have on your subform. Set the tab order of ALL other controls besides the
textbox ones to NO, then check the tab order of the form to make sure it is
all in a correct order. Then add your button to the subform and use some code
like this:

Dim ctl As Control
Dim test As Integer
test = Screen.PreviousControl.TabIndex
test = test + 1
If test > 5 Then
test = test - 5
End If
For Each ctl In Me.Controls
If (ctl.ControlType = acTextBox) Then

If ctl.TabIndex = test Then
ctl.SetFocus
End If
End If
Next ctl

This code assumes that there are 5 controls on the form. Their tab indexes
are 1, 2, 3, 4 and 5. The code will take the tab index of whatever control
had focus before the command button was pressed and then adds 1 to it. Then
it sets focus to the control which has a tab index value to the newly
increased value, until the value is bigger then the highest tab index.
HTH
Good luck
 
I

Indu

Thank you very much your guidance. It is really helpful. And also kindly
explain me how to use key strokes command in vb. to do tab function and down
arrow key. I tried do macro send key function. I am using Access 2003 and
asking me add-in program. How do I use macro send key to do keystrokes.
Please give me web site to learn more about this.
Your kind advices highly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top