I changed scan guns recently from a FedEx scan gun, to a Wasp scan gun. Now when I scan a FedEx label, it gives me a 24 character tracking, and I only need the last 12 digits. I will also be scanning UPS labels and they are alphanumeric. Is there any way to truncate all but the last 12 digits of an all numeric barcode scanned into a text box?
My current code has me leaving off the leading zeros, but if I could just get the last 12 digits, I wouldn't need that piece of code.
Current Code:
Dim strIn As String
Dim i As Integer
Dim iLen As Integer
strIn = Me.txt_Track.Value
iLen = Len(strIn)
For i = 1 To iLen
For i = 1 To iLen
If InStr(strIn, "0") = 1 Then
strIn = Mid(strIn, 2)
End If
Next i
CurrentDb.Execute
"INSERT INTO TrackNum_Table(TrackingNum_TrackNum) " & _
"VALUES ('" & strIn & "')"
This is how I resolved this.
Dim strIn As String
Dim strOut As String
strIn = Me.txt_Track.Value
Numeric = IsNumeric(strIn)
If Numeric = True Then
strOut = Right(strIn, 12)
Else
strOut = strIn
End If
CurrentDb.Execute _
"INSERT INTO TrackNum_Table(TrackingNum_TrackNum) " & _
"VALUES ('" & strOut & "')"