How could I stay my focus on certain Userfrom textbox , don't follow Enter key jump to another botton

Prectice

New Member
Joined
Oct 8, 2014
Messages
16
:confused:

Suppose I have a Userfrom GUI , there are 3 Botton and one textbox on it.

And I want to Scan a barcode and show it on the textbox.

Unforturntly , my barcode scanner will add a Enter keyboard key while it finish

the barcode scan everytime.


Once I Scan any barcode and write down on textbox , and there is a Enter key , be triger after

that. and my focus of Userform will jump to next Botton , never stay at the same textbox.


So , How can I stay the focus on my Textbox only , no matter which times I scan a barcode

on it?


p.s.

1. I try use a setfocus attribute , but no use to this problem.
2. I try to adjust tabindex , but fail to this problem , too.
3. even though I use tbastop = false , but I found the focus is disappear , so I fial again.
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
22,886
Have you tried working with the .EnterKeyBehaviour and .TabKeyBehaviour properties?

At their default setting, False, they set the Return key and the Tab key to change the focus. At, True, those keys do not change the focus away from the text box.
 

Prectice

New Member
Joined
Oct 8, 2014
Messages
16
Have you tried working with the .EnterKeyBehaviour and .TabKeyBehaviour properties?

At their default setting, False, they set the Return key and the Tab key to change the focus. At, True, those keys do not change the focus away from the text box.
Thanks you give me a direction , I will try it tomorrow . But if you give me some code to reference , I will quite appreciate anyways.
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
22,886
I have no experience with barcode scanners, so I have no code to offer.
But if you change those properties in the Properties window and try with your scanner ... its worth a try.

Another idea, leave one other Textobox that will accept focus and put a TextBox1.SetFocus in its Enter event.
 

Forum statistics

Threads
1,085,864
Messages
5,386,404
Members
401,997
Latest member
cizwiz

Some videos you may like

This Week's Hot Topics

Top