Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use EAN13 module in Access 2003 reports

Status
Not open for further replies.

GrahamRutter

Programmer
Oct 2, 2007
5
GB
Hi there,
I have been reading through these forums (very informative).

I am wanting to print a companies full product list as a report (from a product database i have), instead of numerically writing the barcode i would like to show the graphic too.

I found alot of references to the following site which has the module code:

I have created a module using the code from this site (called EAN13) and installed the font (ean13).


Could anyone tell me how i can get the module to run on a textbox (called BARCODE) on my report (called BARCODETEST).
I tried the following line in the textboxes control source:
=EAN13([BARCODE])
...and have changed the font to Code EAN13
But this does not work.


Any help is greatly appreciated
Thanks
Graham
 
graham,
Don't forget to name the function different from the module. If your module is ean13() then the function in the module should be UPCean13() or any other name besides "ean13". change all the references in the module to reflect "mynumber."
Example:
Code:
Function upcean13(ByVal mynumber)
If Len(mynumber) = 13 Then mynumber = Mid(mynumber, 1, 11)

  Dim I%, checksum%, first%, EAN13$, tableA As Boolean
 
  'Vérifier qu'il y a 12 caractères
  If Len(mynumber) = 12 Then
    'Et que ce sont bien des chiffres
    mynumber = "0" & Mid$(mynumber, 1, 12)
Set the font size to about 38pts and adjust the textbox size accordingly.
jim
 
Hi Jim
Thanks for the fast reply.
I have tried making the changes you advised, but there is still no barcodes being displayed.
I have attached my modules code, please let me know where i am going wrong.


Code:
Option Compare Database

Public Function MYEAN13$(ByVal mynumber)
  'This function is governed by the GNU Lesser General Public License (GNU LGPL)
  'V 1.1.1
  'Parameters : a 12 digits length string
  'Return : * a string which give the bar code when it is dispayed with EAN13.TTF font
  '         * an empty string if the supplied parameter is no good
  Dim i%, checksum%, first%, CodeBarre$, tableA As Boolean
  MYEAN13$ = ""
  'Check for 12 characters
  If Len(mynumber) = 12 Then
    'And they are really digits
    For i% = 1 To 12
      If Asc(Mid$(mynumber, i%, 1)) < 48 Or Asc(Mid$(mynumber, i%, 1)) > 57 Then
        i% = 0
        Exit For
      End If
    Next
    If i% = 13 Then
      'Calculation of the checksum
      For i% = 12 To 1 Step -2
        checksum% = checksum% + Val(Mid$(mynumber, i%, 1))
      Next
      checksum% = checksum% * 3
      For i% = 11 To 1 Step -2
        checksum% = checksum% + Val(Mid$(mynumber, i%, 1))
      Next
      mynumber = mynumber & (10 - checksum% Mod 10) Mod 10
      'The first digit is taken just as it is, the second one come from table A
      CodeBarre$ = Left$(mynumber, 1) & Chr$(65 + Val(Mid$(mynumber, 2, 1)))
      first% = Val(Left$(mynumber, 1))
      For i% = 3 To 7
        tableA = False
         Select Case i%
         Case 3
           Select Case first%
           Case 0 To 3
             tableA = True
           End Select
         Case 4
           Select Case first%
           Case 0, 4, 7, 8
             tableA = True
           End Select
         Case 5
           Select Case first%
           Case 0, 1, 4, 5, 9
             tableA = True
           End Select
         Case 6
           Select Case first%
           Case 0, 2, 5, 6, 7
             tableA = True
           End Select
         Case 7
           Select Case first%
           Case 0, 3, 6, 8, 9
             tableA = True
           End Select
         End Select
       If tableA Then
         CodeBarre$ = CodeBarre$ & Chr$(65 + Val(Mid$(mynumber, i%, 1)))
       Else
         CodeBarre$ = CodeBarre$ & Chr$(75 + Val(Mid$(mynumber, i%, 1)))
       End If
     Next
      CodeBarre$ = CodeBarre$ & "*"   'Add middle separator
      For i% = 8 To 13
        CodeBarre$ = CodeBarre$ & Chr$(97 + Val(Mid$(mynumber, i%, 1)))
      Next
      CodeBarre$ = CodeBarre$ & "+"   'Add end mark
      MYEAN13$ = CodeBarre$
    End If
  End If
End Function

Regards
Graham
 
Hi again,

I have just retested...
and it is working, but only if the barcode is 12 digits.
I really need this to work with a 13 digit number, does anyone know how to amend the code to work with 13 digits

Thanks
Graham
 
***UPDATE***

Hi there,
I have changed the line
Code:
If Len(mynumber) = 12 Then
to
Code:
If Len(mynumber) = 13 Then

Now the barcodes are displaying great, thank you very much for your help.

Does anyone know if there is a short version of the EAN13 font?
I need a barcode that takes up less room for ticketing.

Thanks
Graham
 
graham,
I am just fooling around with my ean13, 99.9% of ours are UPCA and I just have the ean13 figure it out for fun. My scanner automatically converts the EAN13's to UPC-A's.(I guess they are going to convert all UPC-A's to EAN13 sometime in the future, unless RFID takes over.)
The size of the barcode depends on your scanner. If it is a "LASER" scanner it will read very small lines (spaces acutally) and the printer is also a factor. A laserjet, or a barcode printer, of course, would be the best. We have some barcodes included with our products that measure slightly less than 15mm and my symbol p304 pro reads them the first shot. We also have a WA5700A that will read the small ones most of the time.
Try reducing the font size to 28 and see if the scanner will read it. Then increase the font a couple of points until the scanner reads...
jim
 
Thanks again for all the advice.

I managed to get the font size down to 20, and the barcodes are still printing/scanning fine.
I also found i could leave the font size and just reduce the textbox height if i wanted shorter/thinner barcodes for labels.

Regards
Graham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top