×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to create EAN 128 with two values in Access

How to create EAN 128 with two values in Access

How to create EAN 128 with two values in Access

(OP)
Hi!

I need to create a barcode (EAN 128) from this string:
(93)7769598967(96)28781797
(Parentheses only for readability.)

I have started with the information found here but don't know how to extend that code to cover EAN 128 and not only Code 128.

I have tried the program that you can download and been able to generate the correct barcode from that one.

But I need to generate the barcode in Access 2000 on a report and somehow add the Functioncode1 before the two separate AI's.

Can anyone help me?

RE: How to create EAN 128 with two values in Access

Which program did you download?
Did you contact them for an Access solution?

DougP, MCP, A+

RE: How to create EAN 128 with two values in Access

(OP)
I downloaded the code and made some changes to it.

To use it, copy the code into a new module. Then use the function to code the values. Functioncode1 is coded with the string Fcn1.

ex.
#zipcode#customernumer
Fcn178541Fcn19876145

CODE

Public Function Code128$(ByVal chaine$)
    'V 1.1.0
    'Parameters : a string
    'Return : * a string which give the bar code when it is dispayed with CODE128.TTF font
    '         * an empty string if the supplied parameter is no good
    'This code is from http://grandzebu.net/informatique/codbar-en/code128.htm
    'I have modified it for EAN 128 use, FCN1 (Function code 1) is coded with the string Fcn1.
    'Markus Larsson 2007-01-23
    Dim i%, checksum&, mini%, dummy%, tableB As Boolean
    Code128$ = ""
    If Len(chaine$) > 0 Then
        'Check for valid characters
        For i% = 1 To Len(chaine$)
            Select Case Asc(Mid$(chaine$, i%, 1))
                Case 32 To 126, 198
                Case Else
                    i% = 0
                    Exit For
            End Select
        Next
        'Calculation of the code string with optimized use of tables B and C
        Code128$ = ""
        tableB = True
        If i% > 0 Then
            i% = 1 'i% become the string index
            Do While i% <= Len(chaine$)
                If tableB Then
                    'See if interesting to switch to table C
                    'yes for 4 digits at start or end, else if 6 digits
                    'First we need to test if the first four characters are Fcn1.
                    'In that case we need to check to digits after them for digits.
                    If (Mid$(chaine$, i%, 4) = "Fnc1") Then
                        i% = i% + 4
                        mini% = IIf(i% = 1 Or i% + 3 = Len(chaine$), 4, 6)
          GoSub testnum
                        i% = i% - 4
                    Else
                        mini% = IIf(i% = 1 Or i% + 3 = Len(chaine$), 4, 6)
          GoSub testnum
                    End If
                    If mini% < 0 Then 'Choice of table C
                        If i% = 1 Then 'Starting with table C
                            Code128$ = Chr$(205)
                        Else 'Switch to table C
                            Code128$ = Code128$ & Chr$(199)
                        End If
                        tableB = False
                    Else
                        If i% = 1 Then Code128$ = Chr$(204) 'Starting with table B
                    End If
                End If
                If Not tableB Then
                    'We are on table C, first we need to check if there is a functioncode.
                    'then we can try to process 2 digits.
                    If (Mid$(chaine$, i%, 4) = "Fnc1") Then
                        Code128$ = Code128$ & Chr$(202)
                        i% = i% + 4
                    Else
                        mini% = 2
          GoSub testnum
                        If mini% < 0 Then 'OK for 2 digits, process it
                            dummy% = Val(Mid$(chaine$, i%, 2))
                            dummy% = IIf(dummy% < 95, dummy% + 32, dummy% + 100)
                            Code128$ = Code128$ & Chr$(dummy%)
                            i% = i% + 2
                        Else 'We haven't 2 digits, switch to table B
                            Code128$ = Code128$ & Chr$(200)
                            tableB = True
                        End If
                    End If
                End If
                If tableB Then
                    'Check to see if the following four digits is Fnc1.
                    If (Mid$(chaine$, i%, 4) = "Fnc1") Then
                        Code128$ = Code128$ & Chr$(202)
                        i% = i% + 4
                    Else
                        'Process 1 digit with table B
                        Code128$ = Code128$ & Mid$(chaine$, i%, 1)
                        i% = i% + 1
                    End If
                End If
            Loop
            'Calculation of the checksum
            For i% = 1 To Len(Code128$)
                dummy% = Asc(Mid$(Code128$, i%, 1))
                dummy% = IIf(dummy% < 127, dummy% - 32, dummy% - 100)
                If i% = 1 Then checksum& = dummy%
                checksum& = (checksum& + (i% - 1) * dummy%) Mod 103
            Next
            'Calculation of the checksum ASCII code
            checksum& = IIf(checksum& < 95, checksum& + 32, checksum& + 100)
            'Add the checksum and the STOP
            Code128$ = Code128$ & Chr$(checksum&) & Chr$(206)
        End If
    End If
    Exit Function
testnum:
    'if the mini% characters from i% are numeric, then mini%=0
    mini% = mini% - 1
    'If the first four digits are Fcn1, then we shall still start with table C => mini% = -1
    If (Mid$(chaine$, i% + mini%, 4) = "Fcn1") Then
        mini% = -1
    ElseIf i% + mini% <= Len(chaine$) Then
        Do While mini% >= 0
            If Asc(Mid$(chaine$, i% + mini%, 1)) < 48 Or Asc(Mid$(chaine$, i% + mini%, 1)) > 57 Then Exit Do
            mini% = mini% - 1
        Loop
    End If
    Return
End Function

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close