VBA barcode code generator not working

Unfortunately I've got 64-bit, and it doesn't work for me with the "Value" .... I've got a couple of other things to try.

I'm using MS Access 2016 on a 64-bit machine, and the code works fine. Initially it didn't. I discovered that because I use "Option Explicit" by default the line of code starting with "Result" failed because "Result" is undefined.

However, I commented out "Option Explicit" and the code starting with "Result" worked OK.

'Result = Barcode_39(Barcode, Me) 'This works IF you comment out Option Explicit

However I would recommend replacing "Result" with "Call" as below, as this works with or without Option Explicit

Call Barcode_39(Barcode, Me) 'This works Either way


I tried "Barcode" both ways, with and without ".Value" both worked..

'Set handle on control.
'Barcode = Ctrl.Value

Barcode = Ctrl

If you have a look at this help article:- Report.Line method (Access) from Microsoft Access, MS demonstrate how to display a rectangular box in red in a Report. This also works OK for me.

I would suggest you set this up by way of a test. This Test might help you locate the problem.
 
Well this is strange!
I decided to make a copy of the textbox which displays the bar code so that I could display the actual number above the barcode.

I removed the "layout view" to allow me to add another text box above the existing one, and I noticed, it wouldn't display the barcode.

To check my Theory that it was the layout view that was causing the issue I reinstated "layout view" and the bar-code Returned!

I did a quick video to demonstrate this:-

James Isle Mercanti - VBA Bar Code Generator -Nifty Access

 
Last edited:
Well this is strange!
I decided to make a copy of the textbox which displays the bar code so that I could display the actual number above the barcode.

I removed the "layout view" to allow me to add another text box above the existing one, and I noticed, it wouldn't display the barcode.

To check my Theory that it was the layout view that was causing the issue I reinstated "layout view" and the bar-code Returned!

I did a quick video to demonstrate this:-

James Isle Mercanti - VBA Bar Code Generator -Nifty Access

@Uncle Gizmo I tried it out, but it still worked for me even when I switch from adding or removing the layout. Sorry.

PS. I am using Access 2016.
 
you do not need to Catch the return value from the function.
the function will only Work on Report and in Print view only

on report view, add a (un)Bound Textbox. set its Visible property to No.
on the Detail's Print event:

=Barcode_39([theHiddenTextboxName], [Report])

save the report and view in Print Preview.

I've just tried your db attachment at my office, unfortunately, when I make the report in the Print Preview mode it showed up the barcode but when I print it it's not working on Win 64 bit MS Access 2013.
 

I haven't tried to print, the most important test! I'll give it a go later.

I would say though, you may well be better off going down the barcode font route, it's the way it's done, and everyone knows about it, so if there are any problems there will be more people that can help you solve them.
 
I have no printer but it prints fine as PDF.
maybe add same to the Format event of the report:

=Barcode_39([theHiddenTextboxName], [Report])
 
I have no printer but it prints fine as PDF.
maybe add same to the Format event of the report:

=Barcode_39([theHiddenTextboxName], [Report])
I am sorry to bother all of you with me, I tried it's the same not working.
maybe something related to this line? Const White = 16777215: Const Black = 0
 
I am sorry to bother all of you with me, I tried it's the same not working.
maybe something related to this line? Const White = 16777215: Const Black = 0
Hi. I am not sure why you're focusing on the code. Didn't you say this same code works for you at home? If so, maybe try to find out what's different between your office and home machines. Just a thought...
 
But my concern is as I stated above, it doesn't work at my office with:
Win10 64bit, Access 2013

To clear up any possible misunderstandings. The fact that it works on the 32-bit and not 64-bit indicates there is a problem with 64-bit which is not uncommon when upgrading very old code as I think you appreciate. However, I couldn't see any of The Usual Suspects. Now completely by accident I removed layout-mode and the barcode disappeared. I'm wondering if your report could be suffering from the same problem. Please check in your report, are the fields that display the barcode in layout mode? You should be able to get an idea how to do this if you look at my video. Alternatively, as some people don't have access to YouTube at work follow this procedure:-

Open the report in design view and select the text box (and its Label) which if you followed the instructions in the code the Textbox should be named "Barcode", if you've changed the name then select the text box with your new name (it should be the invisible text box)...


Make sure you have Selected the Text box and its Label. Right-click, and in the menu options that appear select from the third block of options down, the bottom option "Layout".. From the choices provided select "Tabular" ... Close and save the report and then click the:- "Print Preview" button and see if it now displays the barcode correctly...
 
To clear up any possible misunderstandings. The fact that it works on the 32-bit and not 64-bit indicates there is a problem with 64-bit which is not uncommon when upgrading very old code as I think you appreciate. However, I couldn't see any of The Usual Suspects. Now completely by accident I removed layout-mode and the barcode disappeared. I'm wondering if your report could be suffering from the same problem. Please check in your report, are the fields that display the barcode in layout mode? You should be able to get an idea how to do this if you look at my video. Alternatively, as some people don't have access to YouTube at work follow this procedure:-

Open the report in design view and select the text box (and its Label) which if you followed the instructions in the code the Textbox should be named "Barcode", if you've changed the name then select the text box with your new name (it should be the invisible text box)...


Make sure you have Selected the Text box and its Label. Right-click, and in the menu options that appear select from the third block of options down, the bottom option "Layout".. From the choices provided select "Tabular" ... Close and save the report and then click the:- "Print Preview" button and see if it now displays the barcode correctly...
Thank you so much, I will try it and let you know.
I am sure it will work.
 
Thanks again Uncle Gizmo, I followed your procedure in the post 32
Open the report in design view and select the text box (and its Label) which if you followed the instructions in the code the Textbox should be named "Barcode", if you've changed the name then select the text box with your new name (it should be the invisible text box)...
Make sure you have Selected the Text box and its Label. Right-click, and in the menu options that appear select from the third block of options down, the bottom option "Layout".. From the choices provided select "Tabular" ... Close and save the report and then click the:- "Print Preview" button and see if it now displays the barcode correctly...

Actually the benefit of this code is that you can generate Barcode (Code_39) don't need to install the barcode font to the users (Embedded Barcode).

I am wondering is it possible to get the same Embedded VBA 2D QR code?
 
I am wondering is it possible to get the same Embedded VBA 2D QR code?

I don't know. However something you might want to have a look at and explore. Someone wrote code that builds a QR code in an Excel spreadsheet using the Excel cells as the pixels for the QR code. I think that was done with VBA.

How you would translate that code into building the the QR code in a text box in MS Access, well it would be a challenge to say the least!
 
I will explore that.
Thank you so much, appreciate your usual help.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom