Seperate ID Prefix and ID Number

B

Barry A&P

I am playing with a barcode reader in my database. and from what i can figure
out standard procedure is to set focus to a control then read the scanner.
i am wondering if anybody has any great ideas to have the barcode itself tell
access what to do. here is what i am hoping..

On my report that i use to print barcodes i can concatenate a prefix to each
Barcode type ie; "*LNID" & [locationid] & "*" = Location Barcode, PNID =
PartNumbr, SNID = SerialNumber Ect..

Then with your help of course i would like some code that is somehow linked
to a unbound Control [barcodeScan]
Set the extracted 4 digit prefix from the barcode as CodePrefix
Set remaining digits as CodeNumber

If Code prefix = "SNID" open form "Serialnumbers" find record serialnumber
= Codenumber. (call lookup combos created by the wizard on other forms??)
Else if Codeprefix = "PNID" Open Form "PartNumbers" Find record partnumber =
codenumber.
Else If there is no prefix assume it is a part number and open form part
numbers.. Can i Do this?? because most barcodes from manufactures would not
have my prefix... (worse case is i could have an additional control with a
list of prefixes that would have to be selected prior to scanning a
Non-Prefixed barcode then concatenate the controls prior to running this
code??)

I would only have 4 or 5 prefixes so they may just be referred in code. or
would it not be too complicated to have prefixes in a table with another
field that would open a certain form so the possibility of 20 prefixes could
be "pre Planned"

any help on this code or a complete new direction would be appreciated..

Thanks
Barry
 
J

Jack Cannon

Barry,

You certainly must have the focus set to the proper control otherwise you
would not know where the scanner is sending the data.

I would suggest that you set the scanner to automatically send a LF or CR
character after the scan. This will produce an immediate return after the
data is scanned which will negate the need to depress the Tab or Enter key on
the keyboard in order to continue.

Something like this should accomplish your objective.

Private Sub barcodeScan_AfterUpdate()
On Error GoTo Err_barcodeScan_AfterUpdate

Select Case UCase(Left(Me.barcodeScan, 4))
Case Is = "SNID"
DoCmd.OpenForm "Serialnumbers", acNormal, , "[serialnumber]=" & _
Right(Me.barcodeScan, Len(Me.barcodeScan) - 4)
Case Is = "PNID"
DoCmd.OpenForm "PartNumbers", acNormal, , "[partnumber]=" & _
Right(Me.barcodeScan, Len(Me.barcodeScan) - 4)
Case Is = "XXXX"
' Do something similar
Case Is = "YYYY"
' Do something else
Case Is = "ZZZZ"
' Continue as long as you like
Case Else
DoCmd.OpenForm "PartNumbers", acNormal, , "[partnumber]=" & _
Me.barcodeScan
End Select

Exit_barcodeScan_AfterUpdate:
Exit Sub

Err_barcodeScan_AfterUpdate:
MsgBox "Procedure is barcodeScan_AfterUpdate" & vbNewLine & _
Err.Number & vbNewLine & Err.Description
Resume Exit_barcodeScan_AfterUpdate

End Sub

Jack Cannon


Barry A&P said:
I am playing with a barcode reader in my database. and from what i can figure
out standard procedure is to set focus to a control then read the scanner.
i am wondering if anybody has any great ideas to have the barcode itself tell
access what to do. here is what i am hoping..

On my report that i use to print barcodes i can concatenate a prefix to each
Barcode type ie; "*LNID" & [locationid] & "*" = Location Barcode, PNID =
PartNumbr, SNID = SerialNumber Ect..

Then with your help of course i would like some code that is somehow linked
to a unbound Control [barcodeScan]
Set the extracted 4 digit prefix from the barcode as CodePrefix
Set remaining digits as CodeNumber

If Code prefix = "SNID" open form "Serialnumbers" find record serialnumber
= Codenumber. (call lookup combos created by the wizard on other forms??)
Else if Codeprefix = "PNID" Open Form "PartNumbers" Find record partnumber =
codenumber.
Else If there is no prefix assume it is a part number and open form part
numbers.. Can i Do this?? because most barcodes from manufactures would not
have my prefix... (worse case is i could have an additional control with a
list of prefixes that would have to be selected prior to scanning a
Non-Prefixed barcode then concatenate the controls prior to running this
code??)

I would only have 4 or 5 prefixes so they may just be referred in code. or
would it not be too complicated to have prefixes in a table with another
field that would open a certain form so the possibility of 20 prefixes could
be "pre Planned"

any help on this code or a complete new direction would be appreciated..

Thanks
Barry
 
B

Barry A&P

Jack
Exactly what i was looking for..
Thank You

Jack Cannon said:
Barry,

You certainly must have the focus set to the proper control otherwise you
would not know where the scanner is sending the data.

I would suggest that you set the scanner to automatically send a LF or CR
character after the scan. This will produce an immediate return after the
data is scanned which will negate the need to depress the Tab or Enter key on
the keyboard in order to continue.

Something like this should accomplish your objective.

Private Sub barcodeScan_AfterUpdate()
On Error GoTo Err_barcodeScan_AfterUpdate

Select Case UCase(Left(Me.barcodeScan, 4))
Case Is = "SNID"
DoCmd.OpenForm "Serialnumbers", acNormal, , "[serialnumber]=" & _
Right(Me.barcodeScan, Len(Me.barcodeScan) - 4)
Case Is = "PNID"
DoCmd.OpenForm "PartNumbers", acNormal, , "[partnumber]=" & _
Right(Me.barcodeScan, Len(Me.barcodeScan) - 4)
Case Is = "XXXX"
' Do something similar
Case Is = "YYYY"
' Do something else
Case Is = "ZZZZ"
' Continue as long as you like
Case Else
DoCmd.OpenForm "PartNumbers", acNormal, , "[partnumber]=" & _
Me.barcodeScan
End Select

Exit_barcodeScan_AfterUpdate:
Exit Sub

Err_barcodeScan_AfterUpdate:
MsgBox "Procedure is barcodeScan_AfterUpdate" & vbNewLine & _
Err.Number & vbNewLine & Err.Description
Resume Exit_barcodeScan_AfterUpdate

End Sub

Jack Cannon


Barry A&P said:
I am playing with a barcode reader in my database. and from what i can figure
out standard procedure is to set focus to a control then read the scanner.
i am wondering if anybody has any great ideas to have the barcode itself tell
access what to do. here is what i am hoping..

On my report that i use to print barcodes i can concatenate a prefix to each
Barcode type ie; "*LNID" & [locationid] & "*" = Location Barcode, PNID =
PartNumbr, SNID = SerialNumber Ect..

Then with your help of course i would like some code that is somehow linked
to a unbound Control [barcodeScan]
Set the extracted 4 digit prefix from the barcode as CodePrefix
Set remaining digits as CodeNumber

If Code prefix = "SNID" open form "Serialnumbers" find record serialnumber
= Codenumber. (call lookup combos created by the wizard on other forms??)
Else if Codeprefix = "PNID" Open Form "PartNumbers" Find record partnumber =
codenumber.
Else If there is no prefix assume it is a part number and open form part
numbers.. Can i Do this?? because most barcodes from manufactures would not
have my prefix... (worse case is i could have an additional control with a
list of prefixes that would have to be selected prior to scanning a
Non-Prefixed barcode then concatenate the controls prior to running this
code??)

I would only have 4 or 5 prefixes so they may just be referred in code. or
would it not be too complicated to have prefixes in a table with another
field that would open a certain form so the possibility of 20 prefixes could
be "pre Planned"

any help on this code or a complete new direction would be appreciated..

Thanks
Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top