Hello everyone - I'm using a bar code scanner to read data. When I pull the trigger on the scanner, the information is read/transferred into a text box on a form. Ideally I would like the data to go into the textbox and automatically load another form once the data is read. The original routine I had utilized a textbox_change() routine, but that didn't seem to work - as soon as the first character was read an error was generated (the data I'm inputting is a string of numbers - example 123456-00, but when pressing the trigger only the 1 would come through, then error is generated). I tried putting a pause in there so that the whole string could be read, but then nothing would happen. So then I changed to a textbox_afterupdate() routine. This initially works, but for some reason it only works 1 time, then I'm forced to close that form in order to have my routine continue.
The code I was using with the textbox_change() routine is below:
Private Sub txtJobNumber_Change()
Call OpenWorkbook
End Sub
The OpenWorkbook routine will close the current form, then open another form - I know this code works the way I want it to if I enter the number string manually then hit enter. But it doesn't work in conjunction with the bar code scanner.
The code I'm currently using with the textbox_afterupdate() routine is below:
Private Sub txtJobNumber_AfterUpdate()
If txtJobNumber.Text <> "" Then
Call cmdScanJobEnter_Enter
End If
End Sub
I've added a command button to the form which when pressed calls the OpenWorkbook routine. As I said, this code works as desired, however it will only work once, then I'm forced to close the form after the number string is read from the barcode scanner in order to have my process continue.
Does anyone have any experience using bar code scanners with VBA, or has anyone had similar issues? How have you been able to overcome this? Any suggestions would be appreciated.
Thanks in advance!
Bookmarks