I'm trying to use a barcode scanner to be able to scan a barcode and look up the respective ticket in a table. I am starting by getting the form to split up the barcode as the barcodes are made up as such: 243455-01-050
The first 6 are the order number.
The middle 2 are the ticket number as there can be multiple tickets per an order.
The last 3 are the step numbers as there are multiple steps per a ticket.
So I am using the following code on the AfterUpdate:
Code:
Option Compare Database
'Private Sub CboName_Change()
'Me.DhrScanTxt.SetFocus
'End Sub
Private Sub DhrScanTxt_AfterUpdate()
Dim Status As String
Status = Me.DhrScanTxt
Me.Text26 = Status
Dim SoNum As Long
SoNum = Left(Status, 6)
Me.SoNumTxt = SoNum
Dim DhrNum As Long
DhrNum = Right(Left(Status, 9), 2)
Me.DhrNumTxt = DhrNum
Dim StepNum As Long
StepNum = Right(Status, 3)
Me.StepNumTxt = StepNum
End Sub
Problem is it doesn't seem to update the other text boxes.
I tried "on change" but it then only takes the 2 and opens the vba and tries to type it in there and opens a windows explorer searching for a file?
I closed out the explorer and hover over the highlighted code bit which is [Status = Me.DhrScanTxt] and it says [Me.DhrScanTxt] is null? which doesnt make sense since I just scanned it in and it shows the 2 in the text box.
The way the barcode scanners are made it also does like 5-7 carriage returns after entering the text so I tried the "on enter" property and it works but I since it hits enter several times I end up on one of the other fields. (I don't want to remove those other fields from tab order because It needs to be useable with just a keyboard)
I tried adding a [Me.DhrScanTxt.SetFocus] to the end and it doesn't work. it still goes to the next field since it does several carriage returns.
When I get there I want it to highlight the text so that the user can scan several steps quickly. I haven't figured out how to do that yet so if you know that would be a nice extra bit.
Thanks for taking the time to help!