Hi,
I have a simple userform (for now!) that has two fields/textboxes on it that need to populate when a barcode is scanned.
Problem I have is that I need to populate both with a barcode, mainly for speed, although a user could still type in if they wanted or needed to. One scan would be barcode from a sheet of paper related to the task an employee is doing and the other would be an ID for the user. As I controll the user ID's I am going to prefix them all with 000 as the other barcodes will not have this as a prefix.
What I have tried unsuccesfully to do is to populate Textbox2 ('Scan Read') with the barcode scanner and from there determine if the data should be entered in to either Textbox1 or Textbox3.
I have removed the automatically added 'Tab' from the barcode reader so it stays in the textbox and tried adding in a carriage return to move the cursor but this did not work either. Was looking to see if there is a way to catch the barcode scan instead of populating a textbox but was not able to find anything along this avenue...!
Any help with the code below on how to capture the barcode reading and then determine what textbox the result needs to go in to would be greatly appreciated.
My simple userform showing the top two textboxes that I need to populate and the scan read textbox I am using to capture the barcode scan.
Thanks in advance for any help.
I have a simple userform (for now!) that has two fields/textboxes on it that need to populate when a barcode is scanned.
Problem I have is that I need to populate both with a barcode, mainly for speed, although a user could still type in if they wanted or needed to. One scan would be barcode from a sheet of paper related to the task an employee is doing and the other would be an ID for the user. As I controll the user ID's I am going to prefix them all with 000 as the other barcodes will not have this as a prefix.
What I have tried unsuccesfully to do is to populate Textbox2 ('Scan Read') with the barcode scanner and from there determine if the data should be entered in to either Textbox1 or Textbox3.
I have removed the automatically added 'Tab' from the barcode reader so it stays in the textbox and tried adding in a carriage return to move the cursor but this did not work either. Was looking to see if there is a way to catch the barcode scan instead of populating a textbox but was not able to find anything along this avenue...!
Any help with the code below on how to capture the barcode reading and then determine what textbox the result needs to go in to would be greatly appreciated.
VBA Code:
Private Sub UserForm_Initialize()
TextBox2.SetFocus
End Sub
Private Sub TextBox2_Update()
Dim ScanRead As String
ScanRead = CStr(TextBox2.Value)
MsgBox ScanRead
If ScanRead = "" Then
Else
If Left(ScanRead, 3) = "000" Then
TextBox3.Value = ScanRead
Else
TextBox1.Value = Right(ScanRead, Len(ScanRead) - 3)
End If
End If
TextBox2.Value = ""
SetFocus.TextBox2
End Sub
My simple userform showing the top two textboxes that I need to populate and the scan read textbox I am using to capture the barcode scan.
Thanks in advance for any help.