barcode scanner set focus on VBA

Enchantix

New Member
Joined
Sep 20, 2015
Messages
34
Hi Guys,

I’ve been attempting a setup for the barcode scanner and i just need to get across the line. If you could help me in this it would be appreciated greatly.

i have a user form (image below) with the following requirements;

On the right hand side of the form, you can see a series of textboxes from barcode focus, current barcode all the way to que 4.

firstly the barcode scanner imitates a keystroke combination and will typically finish a scan with a carriage return/ line feed combination.

This means that the scanner imitates a user who types in the data then presses the enter key hence if a barcode is scanned in the ie "barcode focus" text box, the cursor will automatically shift down to "current barcode" text box once the barcode is in the barcode focus text box.

I’ve started the following VBA code...

Private Sub UserForm_Activate()

UserForm1.TxtBox_BarcodeFocus.SetFocus

UserForm1.TxtBox_Barcode_Current.Value = Range("Packnumber!b1").Value


on top of the form i have a text box "current pack #" this textbox has a range ("packnumber!b1").value - found in cell b1 of the packnumber worksheet.

i would like following to occur when the form activates and the focus has been set on the "Barcode focus" text box:

The scanner will scan a barcode which will input the numbers on the "barcode focus" text box (via Bluetooth) as this is the active field in the form, once the barcode is in the field it will be sent immediately to the "current barcode" (text box below).

At the same time the barcode will then be cleared in the "barcode focus" text box and hence the cursor will refocus and return back to the "barcode focus" text box awaiting for another barcode to be scanned.

When another barcode is scanned it will send the barcode to que 1 since "current barcode" text box is occupied by a number scanned earlier and so forth if more barcodes are scanned upto que 4 clearing the "barcode focus" text box each time and refocusing there.

in the user form below you can also see a command button "enter new pack" this button when clicked will also refocus to "barcode focus" textbox after the event has been carried out.

the event will involve sending the barcode number in "current barcode" to the "current pack #" text box on top of the form as indicated earlier. This will inturn shift the que up by one hence, the barcode that is in "que 4" will now move to "que 3" and the barcode in "que 3" will move to "que 2" while "que 1" will move to "current barcode".

this event only takes place when "enter new pack" is clicked.

Is this dream possible?

thank you kindly for any idea or guidance in the right direction.


 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Watch MrExcel Video

Forum statistics

Threads
1,129,752
Messages
5,638,162
Members
417,011
Latest member
Amaden95

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
Top