How to automatically switch to next Entry (Textbox)

usermj

Registered User.
Local time
Today, 03:54
Joined
Dec 12, 2004
Messages
39
On the Form, I get several Textboxes for users to input the value following the sequence. I set the 'TabIndex' value for each TextBox (from 0 to 10).

Is there any chance the system can automatically move the curser (focus) from one Textbox to the next after setting the value?

So without using TabSwitch button on the keyboard or mouse, the system can automatically guide the users to fill all the required textboxes in certain sequence.

Many Thanks :)
 
AfterUpdate

You can do this but the user still has to hit the tab key:

Code:
Private Sub PurchaseOrderNumber_AfterUpdate()
DoCmd.GoToControl "ControlNameHere"
End Sub

Probably a way to do it as you want, I just don't know it!!
:D
 
bit more....?

you mean after the entry has reached 10 in length...? to go to next text box...?

You can if this is the case...

This calls a fucntion so you need not repeat so much code in your db. I didn't text syntax, I just copied from mine and made a few changes, so check syntax, should work quite well though.


chkVarlen MyNextControl 'as parameter

sub chkVarlen(vNextCtrlNM as string)
myVar = Me.ActiveControl.Name
myChk = Me.Controls(myVar).Text
chkLen = Len(myChk)

If chkLen2 = chkLen Then
Me.Controls(vNextCtrlNM).SetFocus
end if
end sub
 
You could even get fancier as I did in my project, I passed the length I wanted each time too and tested against that. so you could pass, next control, and len to check into the function so it is even a more versatile function....
 
Thanks for you guys..

scouser's solution seems to require some manual work on setting the code in each TextBox event, but the most essential solution :) If no other choice, I will stick with this one.

I will try to see if I can play around with Bleslie88's one, which may avoid some duplicated codes.
 
BLeslie88 said:
you mean after the entry has reached 10 in length...? to go to next text box...?

Sorry, I didn;t make myself clear.

I meant I have 10 Textbox on the form. I have set the TabIndex value for each one in the sequence. from 0 to 9.

I hope the system can automatically switch curser from one textbox to another after I fill one textbox. So in this case, we don;t need to use TabSwitch key or mouse to change between textboxes.

According to above discussion, it seems it still requires some manual setting in the afterUpdate event of each Textbox, isn;t it?

or another good way?
 
oops.

On Change Event.

this is where this would be coded...

and when it reaches the length you specify, it will automatically set focus the next text box, with no tab.
 

Users who are viewing this thread

Back
Top Bottom