Results 1 to 7 of 7
  1. #1
    Macallan60 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2010
    Posts
    51

    BarCode VBA

    Hello,



    I'm attempting to create labels with barcodes. The labels will have on the 1st line the barcode, 2nd line is the barcode name and 3rd line is the associate name. I can get lines 2 and 3 to display but not the barcode itself.
    I found the vba online and followed the directions. Can someone please point out what I missed? Attached is a sample database of what I did.

    Thank you for your input.BarCode.accdb

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    This code is supposed to create and display a barcode without a font file?

    In which control on report do you expect to display the barcode? All three textboxes are bound to fields.

    The url in code does not work.

    Was this originally VB project code, not VBA?

    I removed field from Me.txtPkMS_UserID_BarCode and changed code to:

    Me.txtPkMS_UserID_BarCode = Barcode_39(txtPkMS_UserID, Me)

    Barcode shows but appears to be superimposed over text.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Macallan60 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2010
    Posts
    51
    Hi June7. Thanks for the quick reply.

    "This code is supposed to create and display a barcode without a font file?"
    "Was this originally VB project code, not VBA?"
    I'm sorry, I don't know the answer to those questions.

    "
    In which control on report do you expect to display the barcode? All three textboxes are bound to fields."
    txtPkMS_UserID_BarCode

    I found this years ago and thought it maybe useful one day. Maybe it's a long shot but I was hoping someone here may have used this before successfully?

    Thanks for your response.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    So far I figured out code is creating line objects on report to represent a bar code. These lines sit on top of textbox. Textbox must have some data and be Visible for lines to show but then data in textbox shows as well.

    Okay, this works.

    Set ControlSource of Me.txtPkMS_UserID_BarCode to a single space: =" "

    Modify function to pass data as a string and use that for the barcode calc:
    Code:
    Function Barcode_39(Ctrl As Control, rpt As Report, data As String)
    ...
        'Set handle on control - this comment does not seem appropriate
        Barcode = data
    ...
    End Function
    Call the function in report:
    Result = Barcode_39(Me.txtPkMS_UserID_BarCode, Me, Me.txtPkMS_UserID)

    Odd thing is, I found an old db in my collection that uses exact same code as yours and did not have to make these mods to work.
    Last edited by June7; 04-06-2022 at 05:46 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Macallan60 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2010
    Posts
    51
    Thanks for your reply June7.

    "Odd thing is, I found an old db in my collection that uses exact same code as yours and did not have to make these mods to work."
    That is strange.

    I made the changes you suggested and I'm getting a Compile Error. I attached a screenshot of the error. Please let me know where I went wrong.


    Click image for larger version. 

Name:	CompileError.jpg 
Views:	30 
Size:	72.2 KB 
ID:	47641

  6. #6
    Macallan60 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2010
    Posts
    51
    Hey June7,

    I solved it! The solution is a bit strange. The txtPkMS_UserID_BarCode textbox in the labels_tblAssociates report was created using the labels wizard. I just renamed the textbox txtPkMS_UserID_BarCode after finishing the wizard.
    So I deleted the
    txtPkMS_UserID_BarCode textbox and added a new textbox with the same name. The control source was set to PkMS_UserID and Visible was set to No. My barcodes then appeared.

    Thank you for your hard work and suggestions. Much appreciated.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    That is an odd one. I never would have guessed. Another reason for avoiding build wizards. They do things I don't like.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. from barcode record to next barcode record
    By ghallourim in forum Forms
    Replies: 2
    Last Post: 12-22-2021, 08:00 AM
  2. Replies: 5
    Last Post: 05-16-2019, 09:01 PM
  3. Barcode in Report????
    By swedni in forum Reports
    Replies: 2
    Last Post: 01-29-2015, 05:52 AM
  4. Is this barcode a working barcode?
    By panoss in forum Access
    Replies: 2
    Last Post: 11-06-2014, 10:10 AM
  5. barcode
    By techker in forum Access
    Replies: 1
    Last Post: 02-21-2009, 09:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums