Barcodefield in my access report

  • Thread starter Thread starter Luc
  • Start date Start date
L

Luc

Guest
I want to display a barcodeimage in my report and print it out.
I think access can't do this directly,
but i know there are several possibilities or with an activeX or with barcode fonts.
Is there a free (or low budget) EAN8 and EAN13 barcode font (best allso other types) available somewhere or an activeX for in access without license.
I only found trails or demo's on the net where some code are left out.
For now i use barcodesoftware from easy computing, but it would be nice to print the barcode directly from my software through an access report.
Help is greatly appriciated.
 
I have used Jean Marie's VBA script for ean13 barcodes in Excel 2010 combined with an ean13 font it works perfectly. When I try do exactly the same thing using the same script and font in an Access report to display ean13 barcodes in a field I get a blank field. Can anyone help with this?
 
I also used jean marie's code ean13 for Excel but not for Access. have you tried tweaking the font size and/or the text location? I retired and haven't used Access for several years, but I remember the same issue with my code for upc-a. I changed the text box text location from bottom to top or center and it displayed fine. Also the size makes a difference. Seems anything under 16 point did not display well. I just tried my old db and found the upc-a text boxes are all screwed up. Guess I will have to check my code to see what is wrong.
 
I also used jean marie's code ean13 for Excel but not for Access. have you tried tweaking the font size and/or the text location? I retired and haven't used Access for several years, but I remember the same issue with my code for upc-a. I changed the text box text location from bottom to top or center and it displayed fine. Also the size makes a difference. Seems anything under 16 point did not display well. I just tried my old db and found the upc-a text boxes are all screwed up. Guess I will have to check my code to see what is wrong.

The ean13 script when I run it in Excel will convert the barcode number to a series of numbers and letters which when I use the ean13 font in Excel will display as a barcode. If I import the converted barcode number to Access and use the ean13 font it will also display the barcode. The problem seems to be that the ean13 script does not work in Access even though once you load the module Access recognises the function you have created.

This is the script I am using:

Public Function Lean1$(chaine$)
'V 1.0
'Paramètres : une chaine de 12 chiffres
'Retour : * une chaine qui, affichée avec la police EAN13.TTF, donne le code barre
' * une chaine vide si paramètre fourni incorrect
Dim i%, checksum%, first%, CodeBarre$, tableA As Boolean
ean13$ = ""
'Vérifier qu'il y a 12 caractères
If Len(chaine$) = 12 Then
'Et que ce sont bien des chiffres
For i% = 1 To 12
If Asc(Mid$(chaine$, i%, 1)) < 48 Or Asc(Mid$(chaine$, i%, 1)) > 57 Then
i% = 0
Exit For
End If
Next
If i% = 13 Then
'Calcul de la clé de contrôle
For i% = 2 To 12 Step 2
checksum% = checksum% + Val(Mid$(chaine$, i%, 1))
Next
checksum% = checksum% * 3
For i% = 1 To 11 Step 2
checksum% = checksum% + Val(Mid$(chaine$, i%, 1))
Next
chaine$ = chaine$ & (10 - checksum% Mod 10) Mod 10
'Le premier chiffre est pris tel quel, le deuxième vient de la table A
CodeBarre$ = Left$(chaine$, 1) & Chr$(65 + Val(Mid$(chaine$, 2, 1)))
first% = Val(Left$(chaine$, 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$(chaine$, i%, 1)))
Else
CodeBarre$ = CodeBarre$ & Chr$(75 + Val(Mid$(chaine$, i%, 1)))
End If
Next
CodeBarre$ = CodeBarre$ & "*" 'Ajout séparateur central
For i% = 8 To 13
CodeBarre$ = CodeBarre$ & Chr$(97 + Val(Mid$(chaine$, i%, 1)))
Next
CodeBarre$ = CodeBarre$ & "+" 'Ajout de la marque de fin
Lean1$ = CodeBarre$
End If
End If
End Function
 
One possibbility. The functio name cannot be the same as the name in the textbox .
 
should be; Function name cannot be the same as the "Module" NAME
 
Not sure what you mean. The module name is different to the function name in my database, the script won't run if this is not so but the result in the text field where the barcode should be displayed is blank even though the script appears to work. Can you tell me how I need to change the script to make this work.

I cant post an image of my database so I will describe what I am doing using the above script which I have named Barcode_Converter.

Field1 contains the 9 digit barcode number e.g. 9568374058.
Field2 contains the following data source =lean1([Field1]).
Field2 is formatted to ean13 font

This works fine in Excel but in Access Field2 is blank
 
Last edited:
Vin, ean13 is a 13 character barcode. 12 digits and a check sum. I don't think 9 numbers will work. Try entering 3 numbers at the beginning as i think the code auto adds the check sum to make 13.
 
Thank you. I did not realise when I imported the data from Excel that the Barcode No field was limited and not all the digits were imported. Once I fixed this the barcodes display perfectly.
 
Happy that was all it was ;-) Now I have found my Access code is all messed up. Something seems to have changed the ASCI numbers in my code. And , as with yours, my Excel works fine.
 

Users who are viewing this thread

Back
Top Bottom