Printing a barcode on a Label (1 Viewer)

bleakhouse

New member
Local time
Today, 18:28
Joined
Mar 7, 2019
Messages
13
I thought that this would be simple but!

I have a field in a table defined as an attachment, in the field i have attached an image of a barcode.

All i want to do is retreive the picture from the table and print it on a label.

All my code to select the record works, but when I try to retreive the record I get the following error.

Object variable with block variable not set, I must be missing something or not coding correctly.

My code is listed below.

Private Sub PrLabels_Click()
Dim Counter1 As Integer
Dim PlantProductcode As String
Dim PlantName As String
Dim PlantDescription As String
Dim PlantOptions As String
Dim Response As Integer
Dim PlantPrice As Currency
Dim CResponse As String
Dim SearchFor As String
Dim Barcode As String
Dim Barcode2 As Attachment

Dim LabelOutput As String

Dim Recsetop As Recordset
' CResponse = InputBox("Enter (a)ll Labels or (I)ndividual Label")

Set Recsetop = CurrentDb.OpenRecordset("extracted_LabeltoPrint")
CurrentDb.Execute ("Delete * from extracted_LabeltoPrint")

LabelOutput = Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\Hedgerow_Labels.pdf"

PlantProductcode = Me.dataDisplaySubform("code")
PlantDescription = Me.dataDisplaySubform("name")
PlantOptions = Me.dataDisplaySubform("options")
PlantPrice = Me.dataDisplaySubform("price")
Barcode = Me.dataDisplaySubform("barcode")
Barcode2 = Me.dataDisplaySubform("barcode2") - error comes here

Stop

Recsetop.AddNew
Recsetop!code = PlantProductcode
Recsetop!Name = PlantDescription
Recsetop!Options = PlantOptions
Recsetop!Price = PlantPrice
Recsetop!Barcode = Barcode
recetop!Barcode2 = Barcode2
Recsetop.Update

Recsetop.MoveFirst
PlantProductcode = Recsetop("code")
PlantDescription = Recsetop("name")
PlantOptions = Recsetop("options")
PlantPrice = Recsetop("price")
Barcode = Recsetop("barcode")
Barcode2 = Recsetop("barcode2")

Report1Output = Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\HedgerowLabels.pdf" 'Booklet Header

DoCmd.OutputTo acOutputReport, "Print Labels2_Test", acFormatPDF, Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\HedgerowLabels.pdf "

Application.FollowHyperlink Environ("userprofile") & "\desktop\HedgerowLabelsToPrint\Hedgerowlabels.pdf"

end sub

Any help or pointers would be much appreciated

Thanks in anticipation

Regards

Ian Clegg
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:28
Joined
Oct 29, 2018
Messages
21,358
Hi Ian. Just a guess, but see if you get an error with this one.

Code:
Barcode2.FileData = Recsetop("barcode2").FileData
 

Ranman256

Well-known member
Local time
Today, 14:28
Joined
Apr 9, 2015
Messages
4,339
WHERE does the error happen? Since its an object error, I would guess either
the Set Recsetop
or maybe: CurrentDb.Execute
or filedata

help us.
 

bleakhouse

New member
Local time
Today, 18:28
Joined
Mar 7, 2019
Messages
13
WHERE does the error happen? Since its an object error, I would guess either
the Set Recsetop
or maybe: CurrentDb.Execute
or filedata

help us.
I highlighted the error in bold in the code
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:28
Joined
Oct 29, 2018
Messages
21,358
do you thinkthat the rest of the code looks ok?, if I print a label without the barcode it all prints ok
If you want to do this with code, I might say just use an Image control and extract the Attachment to a file using the SaveToFile method.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:28
Joined
May 7, 2009
Messages
19,169
another technique is to use Form for your extracted_LabeltoPrint table.
see the code-behind the button on Form1.
 

Attachments

  • copyAttachment.zip
    64.6 KB · Views: 200

murray83

Games Collector
Local time
Today, 18:28
Joined
Mar 31, 2017
Messages
728
@bleakhouse

here is my ways of printing a bar-code, all of these are printable on a zebra printer, bar the QR code think something to do with the qr code but all print on normal printer as well

hope they help
 

Attachments

  • MU Label Printer with SKU Barcode.accdb
    880 KB · Views: 266
  • Pack Label Printer with SKU Barcode.accdb
    792 KB · Views: 200
  • Print User ID Barcode.accdb
    872 KB · Views: 370
  • QR Barcode Printer.accdb
    760 KB · Views: 346

AccessBlaster

Registered User.
Local time
Today, 11:28
Joined
May 22, 2010
Messages
5,825
Hi Murray83, you may need to have a 64-bit version.

1596840292004.png
 

strive4peace

AWF VIP
Local time
Today, 13:28
Joined
Apr 3, 2020
Messages
1,003
Great link, @Tera, thanks. Steve is a wonderful teacher and covers a lot of advanced topics. He used the Barcode 39 font to demonstrate, which is free, but I don't think it can represent TAB (could be wrong though). Better would be to use a font that came with the scanner, and hopefully the scanner can terminate with Tab. Otherwise, after scanning, the user needs to press TAB (some allow Enter to terminate but for Access Tab is best -- I like to redefine Enter to go to next record not next control or field) or an event needs to run code, like the Change event to determine if there is a second asterisk (typically, with 39, value is surrounded with *) or a Timer event to see if the scan is probably done.

With Access it is good to terminate with TAB in the barcode so after a scan is done, the control AfterUpdate event can be automatically run and focus goes to the next control. This makes it so easy!

Ian, imo, it is best to install the font that the barcode scanner uses, as opposed to taking pictures of printouts and storing them.
Sometimes scanners have different logic than a character-by-character thing -- if this is the case, talk to the manufacturer to get that logic. A barcode font is just a different way to show data -- like you would use Times New Roman, Arial, or Symbol to display your text.

Then scanning is just like typing, so if the scan ends with Tab, then it is like you entered some value and then pressed Tab on the keyboard.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:28
Joined
May 7, 2009
Messages
19,169
is there a font for QRCode? we don't even know what barcode he is using.
 

deletedT

Guest
Local time
Today, 18:28
Joined
Feb 2, 2019
Messages
1,218

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:28
Joined
May 7, 2009
Messages
19,169
i've seen that already.
then how would you Output this as QRCode (using the font you mentioned):

"The Quick Brown Fox Jumps Over The Lazy Dog"

it should generate 1QRCode barcode.
 

deletedT

Guest
Local time
Today, 18:28
Joined
Feb 2, 2019
Messages
1,218
but I don't think it can represent TAB
Although as you suggested the best bet is to use the font that comes with barcode reader, but the last 5 barcode readers I purchased didn't come with the font, nor with a link for download. Instead they had a heavy manual for all sort of settings, for adding Tab or Enter or any other function keys at the beginning or end. I even was able to change the language of the reader.
 
Last edited:

deletedT

Guest
Local time
Today, 18:28
Joined
Feb 2, 2019
Messages
1,218
i've seen that already.
then how would you Output this as QRCode (using the font you mentioned):

"The Quick Brown Fox Jumps Over The Lazy Dog"

it should generate 1QRCode barcode.
I've not used QR codes for a long time. The last time I used them, having the font was not enough. I had to purchase an encoder for generating the QR codes. This is the encoder I purchased. But as I said, it was a long time ago and everything has improved. Maybe there's a way to generate them without an encoder.
 

Users who are viewing this thread

Top Bottom