Can a Text Prefix be De-Concatenated??


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. maybe by something like De-Concatenating?? if there is
anything like that or splitting off the first 4 or 5 charachters frim a
partnumber, Only if the first 4 or 5 match the options i spell out in my
code. here is what i am hoping..

On my report that i use to print barcodes i can concatenate a prefix to each
Barcode type For example "*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] that would seperate the first 4
charachters from the barcode if they match "PNID" SNID" "LNID"

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
 
Ad

Advertisements

M

Mr. B

Hi, Barry,

I would seem that everything you have described is very possible.

I assume that the barcode includes a hard return code that indicates that
the end of the code being scanned. I assume that you can use that
information to initiate code that will do the rest. That part you will have
to work out.

There are a few othere things that may need to be considered but to start
out on the simple side, you indicate that the question about the first
characters may involve "4 or 5" characters. If the number of prefix
characters is not the same then you would need code that be a little more
complicated but here is some code that you can start with.

With that said, extracting the first four characters from the scanned
barcode can be done with code like the untested code below:

'------Start of Code
Dim strBarCode as String
Dim strGetPrefixChars as String
dim strCodeNumber as String

strBarCode = Me.NameOfBarCodeControl
'the line only extracts 4 characters from the start of the barcode
strGetPrefixChars = left(strBarCode,4)
'Next, use a Case statement to determine what to do
'you would need a case for each of the prefixes you expect to get
Select Case strGetPrefixChars
Case "SNID"
'open form and locate record
DoCmd.OpenForm "SerialNumbers", , , _
"PartNumber = '" & strCodeNumber & "'"

Case "PNID"
'open form and locate record
DoCmd.OpenForm "PartNumbers", , , _
"PartNumber = '" & strCodeNumber & "'"

Case Else
'open form for part numbers
DoCmd.OpenForm "PartNumbers"
End Select
'----end of code

I was not clear about what you really want to do when ther is no prefix, but
hopefully this will get you started.

HTH
Mr. B
askdoctoraccess dot com

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. maybe by something like De-Concatenating?? if there is
anything like that or splitting off the first 4 or 5 charachters frim a
partnumber, Only if the first 4 or 5 match the options i spell out in my
code. here is what i am hoping..

On my report that i use to print barcodes i can concatenate a prefix to each
Barcode type For example "*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] that would seperate the first 4
charachters from the barcode if they match "PNID" SNID" "LNID"

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

Mr B
Thank you for your response

I have done a little research on the LEFT procedure and have never used the
"Case" procedure.. I am looking for help more specifically with the
remaining number i believe you referred to it ad StrCodeNumber i did not see
in your example where that comes from?? I will stick to a 5 digit prefix
"PNID-" how do i set the remaining charachters to StrCodeNumber?? as this
number may vary between 3 to 15 didgits. i have found some posts that count
the total charachters in StrBarCode then do something like right
StrBarcodeLength - 5 but this is currently beyond me maybe with a little more
help or research..

Thanks
Barry

Mr. B said:
Hi, Barry,

I would seem that everything you have described is very possible.

I assume that the barcode includes a hard return code that indicates that
the end of the code being scanned. I assume that you can use that
information to initiate code that will do the rest. That part you will have
to work out.

There are a few othere things that may need to be considered but to start
out on the simple side, you indicate that the question about the first
characters may involve "4 or 5" characters. If the number of prefix
characters is not the same then you would need code that be a little more
complicated but here is some code that you can start with.

With that said, extracting the first four characters from the scanned
barcode can be done with code like the untested code below:

'------Start of Code
Dim strBarCode as String
Dim strGetPrefixChars as String
dim strCodeNumber as String

strBarCode = Me.NameOfBarCodeControl
'the line only extracts 4 characters from the start of the barcode
strGetPrefixChars = left(strBarCode,4)
'Next, use a Case statement to determine what to do
'you would need a case for each of the prefixes you expect to get
Select Case strGetPrefixChars
Case "SNID"
'open form and locate record
DoCmd.OpenForm "SerialNumbers", , , _
"PartNumber = '" & strCodeNumber & "'"

Case "PNID"
'open form and locate record
DoCmd.OpenForm "PartNumbers", , , _
"PartNumber = '" & strCodeNumber & "'"

Case Else
'open form for part numbers
DoCmd.OpenForm "PartNumbers"
End Select
'----end of code

I was not clear about what you really want to do when ther is no prefix, but
hopefully this will get you started.

HTH
Mr. B
askdoctoraccess dot com

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. maybe by something like De-Concatenating?? if there is
anything like that or splitting off the first 4 or 5 charachters frim a
partnumber, Only if the first 4 or 5 match the options i spell out in my
code. here is what i am hoping..

On my report that i use to print barcodes i can concatenate a prefix to each
Barcode type For example "*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] that would seperate the first 4
charachters from the barcode if they match "PNID" SNID" "LNID"

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
 
Ad

Advertisements

M

Mr. B

Barry,

Sorry for not including that in the posting. I really intended to.

Also, sorry for taking so long to respond. I have been away from my office.

You will need to use the Mid() function to return the CondNumber value.

Something like:
strCodeNumber = strCodeNumber = Mid(strBarCode, 5, Len(strBarCode) - 5)

Again, I appologze for not having that in the code. It was not much good
without it.

Mr. B
askdoctoraccess dot com



Barry A&P said:
Mr B
Thank you for your response

I have done a little research on the LEFT procedure and have never used the
"Case" procedure.. I am looking for help more specifically with the
remaining number i believe you referred to it ad StrCodeNumber i did not see
in your example where that comes from?? I will stick to a 5 digit prefix
"PNID-" how do i set the remaining charachters to StrCodeNumber?? as this
number may vary between 3 to 15 didgits. i have found some posts that count
the total charachters in StrBarCode then do something like right
StrBarcodeLength - 5 but this is currently beyond me maybe with a little more
help or research..

Thanks
Barry

Mr. B said:
Hi, Barry,

I would seem that everything you have described is very possible.

I assume that the barcode includes a hard return code that indicates that
the end of the code being scanned. I assume that you can use that
information to initiate code that will do the rest. That part you will have
to work out.

There are a few othere things that may need to be considered but to start
out on the simple side, you indicate that the question about the first
characters may involve "4 or 5" characters. If the number of prefix
characters is not the same then you would need code that be a little more
complicated but here is some code that you can start with.

With that said, extracting the first four characters from the scanned
barcode can be done with code like the untested code below:

'------Start of Code
Dim strBarCode as String
Dim strGetPrefixChars as String
dim strCodeNumber as String

strBarCode = Me.NameOfBarCodeControl
'the line only extracts 4 characters from the start of the barcode
strGetPrefixChars = left(strBarCode,4)
'Next, use a Case statement to determine what to do
'you would need a case for each of the prefixes you expect to get
Select Case strGetPrefixChars
Case "SNID"
'open form and locate record
DoCmd.OpenForm "SerialNumbers", , , _
"PartNumber = '" & strCodeNumber & "'"

Case "PNID"
'open form and locate record
DoCmd.OpenForm "PartNumbers", , , _
"PartNumber = '" & strCodeNumber & "'"

Case Else
'open form for part numbers
DoCmd.OpenForm "PartNumbers"
End Select
'----end of code

I was not clear about what you really want to do when ther is no prefix, but
hopefully this will get you started.

HTH
Mr. B
askdoctoraccess dot com

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. maybe by something like De-Concatenating?? if there is
anything like that or splitting off the first 4 or 5 charachters frim a
partnumber, Only if the first 4 or 5 match the options i spell out in my
code. here is what i am hoping..

On my report that i use to print barcodes i can concatenate a prefix to each
Barcode type For example "*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] that would seperate the first 4
charachters from the barcode if they match "PNID" SNID" "LNID"

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