Hello,
I have been using MS Access for quite some time. I am mostly self taught and rely heavily on if..then, and do while...loop statements and occassionaly search for help on these websites if I need something fancy. This has been quite effective and I have been able to produce very helpful databases. However, I have been working on a Point of Sale program recently and I need to print labels to my Zebra LP2824. This printer was used with our previous point of sale and worked fine. I know it still prints because if I hold line-feed when turning it on, it will print the configuration.
However, when I am running code that I found here and many other sites I just can't seem to get any output. None whatsoever. It does spool the file and I notice it in the zebra window when i pause printing. I am unable to get a test page to print for it however. But, I am able to get a test file to print for my canon desktop printer yet the code still doesn't print to it either. So I am kinda at a loss and was hoping perhaps someone could hold my hand through this task.
I am using generic/text only driver as the company that we were using for point of sale said it was necessary. The most recent code I have been working on is from this site and looks like this....Honestly I don't understand much of it, but that has never stopped me from successfully using code that I have found online. A friend of mine mentioned i might need to update the printers firmware...could that be the problem? - Option Compare Database
-
Private Type DOCINFO
-
pDocName As String
-
pOutputFile As String
-
pDatatype As String
-
End Type
-
-
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal _
-
hPrinter As Long) As Long
-
Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _
-
hPrinter As Long) As Long
-
Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _
-
hPrinter As Long) As Long
-
Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
-
"OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
-
ByVal pDefault As Long) As Long
-
Private Declare Function StartDocPrinter Lib "winspool.drv" Alias _
-
"StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
-
pDocInfo As DOCINFO) As Long
-
Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _
-
hPrinter As Long) As Long
-
Private Declare Function WritePrinter Lib "winspool.drv" (ByVal _
-
hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, _
-
pcWritten As Long) As Long
-
-
Private Sub Command8_Click()
-
Dim lhPrinter As Long
-
Dim lReturn As Long
-
Dim lpcWritten As Long
-
Dim lDoc As Long
-
-
-
Dim sWrittenData, sBatchID As String
-
Dim strLine1, strLine2, strLine3 As String
-
Dim MyDocInfo As DOCINFO
-
Dim b() As Byte
-
lReturn = OpenPrinter("canon", lhPrinter, 0)
-
If lReturn = 0 Then
-
MsgBox "The Printer Name you typed wasn't recognized."
-
Exit Sub
-
End If
-
sBatchID = InputBox("Enter the batchID for which labels will be printed", "BatchID", 1)
-
MyDocInfo.pDocName = "AAAAAA"
-
MyDocInfo.pOutputFile = vbNullString
-
MyDocInfo.pDatatype = vbNullString
-
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
-
Call StartPagePrinter(lhPrinter)
-
strLine1 = "^XA^CFD~SD30^FS" 'indicates start of label, and sets darkness to 30
-
strLine2 = strLine1 & "^BY2,3,10^A0N,30,36^BCN,50,Y,N,N,N^FO20,40^FD " & "40600005" & "^FS"
-
'strLine1 = "B190,30,0,1A,3,4,55,B,""" & "456323" & """" this was a test from another site I found with zpl language i tried to add to this one when it didn't work
-
strLine3 = strLine2 & "^PQ5^XZ" '^PQ5 would print 5 copies of the Label
-
-
'MsgBox "string3 to be written is " & strLine3 ' shows what the string looks like
-
'sWrittenData = "B190,30,0,1A,3,4,55,B,""" & "456323" & """" & vbFormFeed
-
'MsgBox "Length of string to printer is " & Len(sWrittenData)
-
'tells me how long the string is
-
'MsgBox "string to be written is " & sWrittenData 'shows what the string looks like that will actually be printed
-
sWrittenData = strLine3 & vbFormFeed
-
-
b = StrConv(sWrittenData, vbFromUnicode)
-
-
lReturn = WritePrinter(lhPrinter, b(0), UBound(b) + 1, lpcWritten)
-
-
'lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, Len(sWrittenData), lpcWritten)
-
lReturn = EndPagePrinter(lhPrinter)
-
lReturn = EndDocPrinter(lhPrinter)
-
lReturn = ClosePrinter(lhPrinter)
-
End Sub
please please help!
PS. Oh yeah....I am using Access 2007-2010.
You're a new user, so I'll try to be gentle.
Before posting code check out When Posting (VBA or SQL) Code. It will help you do things the right way which will save time for you too, as well as make it easier for us to help you. Also consider when posting code, that including lines that have already been commented out indicating they are not required helps no-one (Not us nor you). Time spent preparing a question can make so much difference to how likely you are to get a helpful answer.
In this case, the problem is barely even related to the code I guess, and is more likely either something in the printer setup on the individual PC or the printer itself (This might include some of the literal data sent to the printer but we would need intimate knowledge of the printer in order to help with this, or even recognise what might be causing your issue).
I applaud you for you ingenuity in being able to make such good use of the resources available to you, but your not being the author of the code leaves you unable to explain much that we would almost certainly need to be informed of about what it's doing in order to assist.
Little good news I know, but I suspect and hope that doesn't put you off from asking other questions when you have the need. Not all questions will be as unlikely to find help as this one I suspect.
Good luck anyway :-)
7 6638 NeoPa 32,556
Recognized Expert Moderator MVP
You're a new user, so I'll try to be gentle.
Before posting code check out When Posting (VBA or SQL) Code. It will help you do things the right way which will save time for you too, as well as make it easier for us to help you. Also consider when posting code, that including lines that have already been commented out indicating they are not required helps no-one (Not us nor you). Time spent preparing a question can make so much difference to how likely you are to get a helpful answer.
In this case, the problem is barely even related to the code I guess, and is more likely either something in the printer setup on the individual PC or the printer itself (This might include some of the literal data sent to the printer but we would need intimate knowledge of the printer in order to help with this, or even recognise what might be causing your issue).
I applaud you for you ingenuity in being able to make such good use of the resources available to you, but your not being the author of the code leaves you unable to explain much that we would almost certainly need to be informed of about what it's doing in order to assist.
Little good news I know, but I suspect and hope that doesn't put you off from asking other questions when you have the need. Not all questions will be as unlikely to find help as this one I suspect.
Good luck anyway :-)
Hello NeoPa,
Thank you for being gentle. I will try to have my post properly edited next time. It helps to know that the problem is likely with the printer and not the code. There are no errors in the code that stop it from running, but I wasn't sure since I can't even get the desktop printer to print anything. The file does spool though, so makes me think it is being sent to the printer, but the printer can not understand what I am asking it to do.
Thanks,
Cwebb
NeoPa 32,556
Recognized Expert Moderator MVP
This is off Access now, but does the spool go to the printer but never finish, or does it fail ever even to start?
BTW I'm not actually saying that the fix is not associated with the code somewhere, just that the expertise you need is not that of a typical Access expert, but more requires knowledge of the specific printer and/or maybe of the printing systems of Windows.
Hello NeoPa,
Thank you for your continued efforts to assist me. I was able to solve my problem. Your initial response was correct. The code did send the batch to the printer; I just was using ZPL instead of EPL printer language and even when I was using EPL, I had some errors.
After messing with the format of the printer commands I have been able to successfully format it and the printer is working wonderfully. I needed to remove the space I had in quotes just before the data to be sent and I also needed to include the chr(34). In addition, I needed to include the vbCrLf commands. It helped me to concatenate the entire file into one line of code, but that just might have been me.
Anyway, here is the formatting that worked for me: -
sWrittenData = "N" & vbCrLf & "B30,30,0,1A,1,2,55,B," & _
-
Chr(34) & e & Chr(34) & vbCrLf & "A30,135,0,1,1,1,N," & _
-
Chr(34) & w & Chr(34) & vbCrLf & "A240,30,0,1,3,6,N," & _
-
Chr(34) & y & Chr(34) & vbCrLf & "P1" & vbCrLf
-
Thanks again,
cwebb
NeoPa 32,556
Recognized Expert Moderator MVP
Nice :-)
Let me see if I can help you make that a little easier to read and work with. You probably understand by now how important that is, having fallen over the confusion of it earlier : - sWrittenData = "N%L" & _
-
"B30,30,0,1A,1,2,55,B,""" & e & """%L" & _
-
"A30,135,0,1,1,1,N,""" & w & """%L" & _
-
"A240,30,0,1,3,6,N,""" & y & """%L" & _
-
"P1%L"
-
sWrittenData = Replace(sWrittenData, "%L", vbCrLf)
NB. A double-quote character (") can be written within a string in VBA as two of them (""). VBA resolves this for you. It's actually easier to read and understand than having Chr(34) dotted around your code. You can look up Replace() in Context-Sensitive Help, but it this case it replaces all occurrences of " %L" in the string with vbCrLf (which incidentally can also be written as vbNewLine).
Anyway, nice work.
Those are some really slick tricks. They will speed my project up quite a bit. Thanks alot!
NeoPa 32,556
Recognized Expert Moderator MVP
A pleasure of course. Even more so as they're appreciated as intended :-)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Twist Around |
last post by:
We have to use a zebra printer to print some specialty labels. I was
wondering if anyone had used python to output text to these. I know
they use the Zebra Printing Language and before we got into...
|
by: dzemo |
last post by:
I have mentioned printer but how to print on him from code? I tried like POS
printer copy .txt to LPT port but don't work. I tried print test page- still
nothing. Any ideas?
thx
--...
|
by: Mika M |
last post by:
Hi all!
I have made an application for printing simple barcode labels using
PrintDocument object, and it's working fine.
Barcode printer that I use is attached to the computer, and this...
|
by: VJ |
last post by:
I am able to print to File, which I am doing fine in our Program now. I want
to be able to take this file and Print to a printer.
Vijay
|
by: Beginner |
last post by:
I have to print a Fedex shipping label on a Zebra(thermal) printer. I
initially had the label information in a base64 string which I decoded into a
memory stream. Now I need to send this memory...
| |
by: ATJaguarX |
last post by:
I have a Zebra S500 and multiple S600 label printers.
http://www.zebra.com/id/zebra/na/en/index/products/printers/industrial_commercial/s600.html
They are currently being used in our legacy...
|
by: steve |
last post by:
Hi All
Has anybody had experience with printing text and barcodes to Zebra label
printers in VB.net 2005
Regards
Steve
|
by: cchen1682005 |
last post by:
Hi, I am writing an application in C#. Which can adjust the printing position of a Zebra printer, 110XiIII through program instesd of setting on Zebra's panel.
Any help on this would be greatly...
|
by: bernardolira |
last post by:
Hi all.
I made a VB6 program to manage articles using barcodes, and got stuck trying to print barcodes. My printer is a Zebra TLP 2742 (Eltron 2844Z I guess).
If I try to print using the EPL...
|
by: Raymond |
last post by:
Hi All,
Has any one work with FedEx Webservice with ASP?
I am using ASP via SOAP to talk to FedEx Webservice, I have no problem
printing the FedEx label with PNG or PDF, my problem is to print...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |