What is the best way to store bar code in database

FuzMic

DataBase Tinker
Local time
Today, 08:15
Joined
Sep 13, 2006
Messages
739
Hi gurus

When i scan a barcode in what form is the information being captured? How should the captured info be kept in a database.
 
Basically, depends on the scanner, but they usually translate the bar-code into a string of digits. If the digits are never more than 9 digits long, you COULD store them in a LONG - but I wouldn't bet on it not containing something that would disqualify use of any numeric format. So I would just shoot straight for a short text string long enough to hold the maximum number of expected digits (and any possible punctuation marks).
 
Hi. As far as I know, barcode data are usually stored as Text. To display the text value as a barcode, you use a barcode font.
 
There's a Blog here which will give you some general information about barcodes:-


As already stated, you store the barcode information in a text field in a table.

Most barcode scanners are set up ready to go, one mistake people make is changing the barcode scanners settings. If you have a second-hand barcode scanner, it's settings may have been changed my previous owner. In this case it would probably be best to do a factory reset.

The settings are usually controlled by a set of barcodes supplied with the barcode scanner. Make sure you get those with it, if you buy a second-hand one.
 
Now I have a mental jam. Let's say I have the database with a string field holding all the barcodes. If I want to find If a particular code exist I presume I have to open an input form to hold the to be scanned string code. Once the code is in then I have to scan all existing record to see if it already exist. Is this the way to go? Any better way?
 
you can use BeforeUpdate event of the Textbox to check if the barcode already exists
on the table:

private sub textbox1_BeforeUpdate(Cancel As Integer)
If DCount("1", "yourBarCodeTableName", "barCodeField = '" & Me!textbox1 & "'") <> 0 Then
Cancel = True
Msgbox "Barcode already exists! Please try another code."
End If
end sub
 
Bro that is what I do if I use Item ID .. thanks for your time ... appreciate
 
Barcodes should be unique within an application so you should also add a unique index for the bar code field. This also speeds up and access to the record.
 
I presume I have to open an input form to hold the to be scanned string code. Once the code is in then I have to scan all existing record to see if it already exist.

That's the way I do it, but @arnelgp has shown me another way!

Thanks Arnel!
 
When i scan a barcode in what form is the information being captured? How should the captured info be kept in a database.
It depends on the bar code standard been used by the scanner, but as @The_Doc_Man as written, it's normally stored as strings of digits, but some can store as strings of lines or dots.
 
RogerCooper makes a good point. It would depend on usage, but if the 0 is significant, don't use a number to hold the code. If the presence or absence of the digit 0 makes a difference (vs. having a blank in place of the digit 0), then the digits are being used as characters rather than as parts of a number. When making formatting decisions, it is "intended usage" that must be your guide.
 

Users who are viewing this thread

Back
Top Bottom