you can concatenate your data into the format you want. what exactly are you trying to accomplish? If you want more help you have to provide more details.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
The font idea will work ok on most computers but I have had some problems with it. I found the following code works much better. Just creat a new module and past this in it. Then follow the instructions for adding the barcodes to your reports.
Option Compare Database 'Use database order for string comparisons
Option Explicit
'
' mod_BarCode_Generator_Code39
'
' Barcode Generator for Code 3 of 9, Code 39, and Mil-spec Logmars.
'
' version 2.0 (updated for MsAccess 97)
'
' (c) 1993-1999 James Isle Mercanti, Cocoa Beach, FL 32931 USA
' Permission granted for public use and royalty-free distribution.
' No mention of source or credits is required. All rights reserved.
'
' TO USE THIS CODE:
'
' 1 - Create Report with a TextBox control. (example named Barcode)
' Make sure the Visible property is set to "No".
' 2 - Set On-Print property of section to [Event Procedure]
' by clicking on the [...] and selecting "Code Builder"
' 3 - Confirm that the following code matches yours...
'
' Sub Detail1_Print (Cancel As Integer, PrintCount As Integer)
'
' Result = MD_Barcode39(Barcode, Me)
'
' End Sub
'
' 4 - NOTE: The name of the section is "Detail1" for example only!
' Your section might show a different name. Ditto for "Barcode".
'
' 5 - NOTE: To use on sub-forms, the Report name should be hard-coded
' into the function. i.e. Rpt = Reports!MainForm!SubForm.Report.
' The easy method is to just avoid using sub-forms and sub-reports.
'
Function MD_Barcode39(Ctrl As Control, rpt As Report)
On Error GoTo ErrorTrap_BarCode39
Dim Nbar As Single, Wbar As Single, Qbar As Single, Nextbar As Single
Dim CountX As Single, CountY As Single, CountR As Single
Dim Parts As Single, Pix As Single, Color As Long, BarCodePlus As Variant
Dim Stripes As String, BarType As String, Barcode As String
Dim Mx As Single, my As Single, Sx As Single, Sy As Single
Const White = 16777215: Const Black = 0
Const Nratio = 20, Wratio = 55, Qratio = 35
'Get control size and location properties.
Sx = Ctrl.Left: Sy = Ctrl.TOP: Mx = Ctrl.Width: my = Ctrl.Height
The module poeted works well, AFAICS. It does "overwrite" the barcode in the textbox, which is not the "norm", at least as far as my limited understanding goes. Perhaps you could 'expand' the directions a bit to help me place the actual barcode symbology in a seperate "control"?
Also, the schema appears to be what I would expect for all of the various instances of bar codint (ISBN, EAN, ... ) with just a different assignment table ("Function MD_BC39"), do you know if this is true and if so where one might get the alternative assignmnet tables?.
By setting the Textbox control to "No" you will no longer see the data in the text box. This means you don't need to change the font and only the barcode will show when printed.
1 - Create Report with a TextBox control. (example named Barcode) Make sure the Visible property is set to "No".
The word "barcode" can be replaced with any txtbox.
Sub Detail1_Print (Cancel As Integer, PrintCount As Integer)
'
' Result = MD_Barcode39(Barcode, Me)
'
End Sub
Not sure I understand what you are asking for in the second question but I also have the code for 128A and 128B.
Here is the code for the 128A Barcode... You use it the same way as the 3 of 9 code shown earlier.
Option Explicit
' Written by Rodney Marr (RodMarr@mailcity.com) October 7, 2000
' Modified to 128A by Mike Lightner 12 Apr 2004
'
' Barcode 128-A Generator
'
' Permission granted for public use and royalty-free distribution.
' No mention of source or credits is required.
'
' I got a lot of help from the following people's work
' Russ Adams' BarCode 1 Web Page
' A Free 128-B code generator in Visual Basic by Rodney Marr
' And the Creator of the code 39 Module
'
' TO USE THIS CODE:
'
' 1 - Create Report with a TextBox control. (example named Barcode)
' Make sure the Visible property is set to "No".
' 2 - Set On-Print property of section to [Event Procedure]
' by clicking on the [...] and selecting "Code Builder"
' 3 - Confirm that the following code matches yours...
'
' Sub Detail1_Print (Cancel As Integer, PrintCount As Integer)
'
' Result = SetBarDataA(Barcode, Me)
'
' End Sub
'
' 4 - NOTE: The name of the section is "Detail1" for example only!
' Your section might show a different name. Ditto for "Barcode".
'
' 5 - NOTE: To use on sub-forms, the Report name should be hard-coded
' into the function. i.e. Rpt = Reports!MainForm!SubForm.Report.
' The easy method is to just avoid using sub-forms and sub-reports.
Public Function SetBarDataA(Ctrl As Control, rpt As Report)
On Error GoTo ErrorTrap_SetBarDataA
'Code 128A has 5 main parts to it. The first part is a start character(211214), followed by DataCharcters. The Data
'Characters are followed by a check(or Checksum) Character, and that is followed by a stop Character(2331112)
'The last part of Code 128A is the two quiet sections at the front and back of the barcode. These are 10 dimensions
'Long(I am thinking that is 11 modules long). Each character is 11 modules long, except the stop character which is
'13 modules long
Dim CharNumber As Variant, CharData As Variant, CharBarData As Variant, Nratio As Variant, Nbar As Variant
Dim barcodestr As String, Barcode As String, Barchar As String, Barcolor As Long, Parts As Integer, J As Integer
Dim tsum As Integer, lop As Integer, s As Integer, checksum As Integer, p As Integer, barwidth As Integer
Dim boxh As Single, boxw As Single, boxx As Single, boxy As Single, Pix As Single, Nextbar As Single
Const White = 16777215: Const Black = 0
barcodestr = "211412" 'Add the Startcode for Start A (characterset A) to the barcode string
tsum = 103 'And this is the value for that startcode which will be added with the other character values to find the checksum character
boxx = Ctrl.Left: boxy = Ctrl.TOP: boxw = Ctrl.Width: boxh = Ctrl.Height 'Get control size and location properties.
Barcode = UCase(Ctrl) 'Set handle on control and change all lower case letters to uper case.
Nratio = Array("0", "15", "30", "45", "60") 'Set up the array for the different bar width ratios
Parts = ((11 * (Len(Barcode))) + 35) * Nratio(1) 'This is the formula for the width of the barcode
Pix = (boxw / Parts) 'Here I find out exactly how many Pixels a bar will be
Nbar = Array((Nratio(0) * Pix), (Nratio(1) * Pix), (Nratio(2) * Pix), (Nratio(3) * Pix), (Nratio(4) * Pix)) 'Set up the array to handle the pixels for each type of bar
'Loop through all bardata to count the sum for all characters and add barcode charcter strings the to the barcode string
For lop = 1 To Len(Barcode)
Barchar = Mid(Barcode, lop, 1)
If Barchar = " " Then Barchar = "SP"
For s = 0 To UBound(CharData)
If Barchar = CharData(s) Then
barcodestr = barcodestr & CharBarData(s) 'This is where I added the character strings to each other to make one long string of 1's, 2's, 3's, & 4's
tsum = tsum + (CLng(CharNumber(s)) * lop) 'Here every barcode character's number value is multiplied by its position in the line and added to tsum
'The actual formula for find the the Checksum is "(104 + (1 * CharcterNumber) + (2 * CharcterNumber) + ...)/103" You would Use the Remainder as
'The Checksum Character. In the case of "BarCode 1" the formula would look
'like "(104+(1*34)+(2*65)+(3*82)+(4*35)+(5*79)+(6*68)+(7*69)+(8*0)+(9*17))/103=20 with Remainder of 33" Therefore the checksum would equal 33
Exit For
End If
Next s
Next lop
checksum = tsum - (Int(tsum / 103) * 103) 'Here I use the the totat sum (tsum) to find the checksum
barcodestr = barcodestr & CharBarData(checksum) & "2331112" 'Here I add the checksum then the stop character into the barcode string
'lets do some initialization
Barcolor = Black
Nextbar = boxx + 11 'I added the 20 for the whitespace (or quiet space) at the beginning of the barcode
'Draw the Barcode
For J = 1 To Len(barcodestr)
Barchar = Mid(barcodestr, J, 1) 'Reuse variable barchar to store the character to be drawn
barwidth = CInt(Barchar) 'Change the barcode charcter into an integer so I can use in the array part of the next line
rpt.Line (Nextbar, boxy)-Step(Nbar(barwidth), boxh), Barcolor, BF 'Draw the line
Nextbar = Nextbar + Nbar(barwidth) 'Calculate the next starting point
If Barcolor = White Then Barcolor = Black Else Barcolor = White 'Swap line colors
Next J
Info only. You might want to check out Jean-Marie's site. Extremely well done barcode explanation, modules, stand alone VB .exe files and includes fonts.
jim
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.