Automatic Advancement To Next Textbox (1 Viewer)

lhooker

Registered User.
Local time
Today, 02:42
Joined
Dec 30, 2005
Messages
399
What is needed to move to the next textbox automatically without tabbing ?

Current settings are as follows for all textboxes.

Tab Index is 12
Tab Index is 13
Tab Index is 14
Tab Index is 15
Tab Index is 16
Tab Index is 17
Tab Index is 18
Tab Index is 19
Tab Index is 20

Tab Stop Yes
Auto Tab is Yes
Vertical is No
 

June7

AWF VIP
Local time
Yesterday, 22:42
Joined
Mar 9, 2014
Messages
5,488
Enter key should do that unless you change the control's EnterKeyBehavior property. Also, Options>Client Settings>Move After Enter sets the default action for Enter key.
 

lhooker

Registered User.
Local time
Today, 02:42
Joined
Dec 30, 2005
Messages
399
I want to automatically advance to the next textbox after entering a numeric value.
 

June7

AWF VIP
Local time
Yesterday, 22:42
Joined
Mar 9, 2014
Messages
5,488
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 07:42
Joined
Sep 21, 2011
Messages
14,343
Nonsense. Obviously, ACCESS has no way of knowing you have entered the entire number unless you hit the Enter or Tab key.
You would need to check you have the correct number of characters before setting focus to the next control?
 

LarryE

Active member
Local time
Yesterday, 23:42
Joined
Aug 18, 2021
Messages
592
You would need to check you have the correct number of characters before setting focus to the next control?
Yes. The key word is "You". ACCESS has no way of knowing does it?
 

GPGeorge

George Hepworth
Local time
Yesterday, 23:42
Joined
Nov 25, 2004
Messages
1,899
It should be possible to write code on the control's Change event to count the number of characters entered and advance to the next control when the required number of characters have been entered. The key, of course, is in having one required number of characters--no more and no less. If the number of characters entered varies, this is an extremely tough nut to crack.
 

LarryE

Active member
Local time
Yesterday, 23:42
Joined
Aug 18, 2021
Messages
592
Well I'll be damned. It turns out I don't know everything there is to know in the universe after all. You can, in fact, count the number of characters in a text box using the On Change event. I have a text box named SearchLibrary, so I can count the characters after every character entry by using:
Len(Me.SearchLibrary.Text)
in the SearchLibrary On Change event.
So then you can go to another control name if Len(Me.TextBoxName.Text) reaches your desired maximum text lengh.
It's still going to be complicated for the OP with several controls involved, but it is possible.
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:42
Joined
Jan 23, 2006
Messages
15,383
What exactly is the rationale for not using the enter key?

Does each textbox require the same number of characters?
I agree with GPG, it seems a lot of work.
You could have a function to compare the number of characters entered vs the number of characters required. But it really depends of the business requirement.
 

LarryE

Active member
Local time
Yesterday, 23:42
Joined
Aug 18, 2021
Messages
592
What exactly is the rationale for not using the enter key?

Does each textbox require the same number of characters?
I agree with GPG, it seems a lot of work.
You could have a function to compare the number of characters entered vs the number of characters required. But it really depends of the business requirement.
Each individual textbox is going to have to be coded in its On Change event according to each character requirement and then tested for that requirement and then if the requirement is met moving to the next control. That means if the character number requirement is 4 and the number input is 6, the OP is going to have to format the textbox to accept 3 leading zeros before the number 6. I thinks it's nuts but it's not my app.
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:42
Joined
Jan 23, 2006
Messages
15,383
Thanks for the update LarryE, but I wanted the OP (lhooker) to describe the business rationale for this.
Are you guessing the requirement or do you know that is what is required?
I tend to agree with your "I thinks it's nuts but it's not my app.", but the OP hasn't provided info as to "why" this is needed. There may be many ways to effect the desired outcome, but counting characters based on On Change would seem to be far down the list.
 

LarryE

Active member
Local time
Yesterday, 23:42
Joined
Aug 18, 2021
Messages
592
Thanks for the update LarryE, but I wanted the OP (lhooker) to describe the business rationale for this.
Are you guessing the requirement or do you know that is what is required?
I tend to agree with your "I thinks it's nuts but it's not my app.", but the OP hasn't provided info as to "why" this is needed. There may be many ways to effect the desired outcome, but counting characters based on On Change would seem to be far down the list.
Yes I understand that. The requirement I am taking about is the character requirement for each textbox. The OP didn't say. The example I gave was just an example. If the text box character requirement number is 4 characters before moving to the next control, then the textbox needs to be tested for 4 characters. If the number 6 is the number the user wants in the textbox, then 0006 needs to be entered.
 

June7

AWF VIP
Local time
Yesterday, 22:42
Joined
Mar 9, 2014
Messages
5,488
If a specific number of characters (or digits) is required, why bother with complex VBA in Change event? - use input mask as suggested in post 4.

If variable length input is permitted, I do not see a solution.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:42
Joined
Feb 19, 2002
Messages
43,331
What exactly is the rationale for not using the enter key?
The enter key should be used to move to a new record, just as the "return/enter" key on the typewriter we used for over 150 years was used to move to a new line. This is muscle memory at work. Don't change something that doesn't need changing.

The logical way to move from control to control is to use the Tab key rather than changing the default key functionality to make them work illogically.

I agree with @June7 's #13 response.
 

Users who are viewing this thread

Top Bottom