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.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,215,007
Messages
6,122,670
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top