What is the best way to store bar code in database (1 Viewer)

FuzMic

DataBase Tinker
Local time
Today, 09:27
Joined
Sep 13, 2006
Messages
719
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.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
, 20:27
Joined
Feb 28, 2001
Messages
27,393
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).
 

theDBguy

I’m here to help
Staff member
Local time
, 18:27
Joined
Oct 29, 2018
Messages
21,581
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.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 02:27
Joined
Jul 9, 2003
Messages
16,393
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.
 

FuzMic

DataBase Tinker
Local time
Today, 09:27
Joined
Sep 13, 2006
Messages
719
Thank you friends for your input
 

FuzMic

DataBase Tinker
Local time
Today, 09:27
Joined
Sep 13, 2006
Messages
719
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?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:27
Joined
May 7, 2009
Messages
19,249
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
 

FuzMic

DataBase Tinker
Local time
Today, 09:27
Joined
Sep 13, 2006
Messages
719
Bro that is what I do if I use Item ID .. thanks for your time ... appreciate
 

Pat Hartman

Super Moderator
Staff member
Local time
, 21:27
Joined
Feb 19, 2002
Messages
43,603
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.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 02:27
Joined
Jul 9, 2003
Messages
16,393
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!
 

oleronesoftwares

Passionate Learner
Local time
, 18:27
Joined
Sep 22, 2014
Messages
1,159
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.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
, 20:27
Joined
Feb 28, 2001
Messages
27,393
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

Top Bottom