?
Solved

Send a String to a printer

Posted on 2003-03-18
17
Medium Priority
?
300 Views
Last Modified: 2011-10-03
We just receive a new printer "Brady 200 MVP" and I have to create a program in access that will take a serial number from a bar code and print it on a small void sticker "1 1/2' / .5'". the code to print the sticker is working "I tested it by copying the code to lpt1 in DOS". my problem is that when I try to do the same thing with access, it always generate me errors. I could program access to insert the string into a text file and then call a batch file that would print it but I would rather use only one program.

I tried to use Printer.print but could'nt get this option, when I type printer.pr I only get
printer.PrintQuality

I am sure there must be an easier way than sending the string and then calling a batch file to do send the text file to the printer but im stuck.

0
Comment
Question by:PetitSinge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 6
17 Comments
 
LVL 3

Expert Comment

by:QJohnson
ID: 8162878
The intellisense doesn't work right for the Print method of the Printer object; it takes a huge amount of faith to type it out and expect it to work.

But it does!!

So just use

   Printer.Print "my string here"

to get it to the printer for you (after you have done the proper setup work, of course.

and don't forget to .EndDoc
0
 

Author Comment

by:PetitSinge
ID: 8166269
could you give me more information about what you mean by the EndDoc, Im newbie and not sure where I have to put that

tnx.
0
 

Author Comment

by:PetitSinge
ID: 8166362
I found this code

Open "LPT1:" For Output As #1
Print #1, StrName
Close #1

from

http://www.experts-exchange.com/Databases/MS_Access/Q_20084858.html

it work, but I have to use another program first "Bar One" for the printer to print the information on the sticker

any clue from where this error may come from ???
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:PetitSinge
ID: 8166364
I found this code

Open "LPT1:" For Output As #1
Print #1, StrName
Close #1

from

http://www.experts-exchange.com/Databases/MS_Access/Q_20084858.html

it work, but I have to use another program first "Bar One" for the printer to print the information on the sticker

any clue from where this error may come from ???
0
 
LVL 3

Accepted Solution

by:
QJohnson earned 440 total points
ID: 8169132
Here is the short list of things you can do with the Printer object in VB/VBA.  These are probably all you need.

To find out the current printer:
========================================
   strCurrentPrinter = Printer.DeviceName
========================================

To get a list of all available printers
========================================
   Dim prTest as Printer
   For each prTest in Printers
         '  code to add prTest.DeviceName to your list device
   Next
========================================

To set a printer to a name you already know (perhaps user selected from your list device)
========================================
   Dim PrTest As Printer
   
   For Each PrTest In Printers
         If PrTest.DeviceName = cboPrinters.Text Then
            Set Printer = PrTest
            Exit For
         End If
   Next
========================================

To print something simple:  
========================================
      Printer.Print ""
      Printer.Print ""
      Printer.Print ""
      Printer.Print "This is a test"
      Printer.EndDoc
========================================


Basically, the story is simple.  The Printer object always exists and you can use it without declaring or instatiating.  It only can use the default printer.  You can set the default printer with the code above.  It is probably good ettiquette to set it back after you finish.

0
 

Author Comment

by:PetitSinge
ID: 8169493
I think you misunderstood me

the printer works fine with

Open "LPT1:" For Output As #1
Print #1, Data1
Close #1

BUT, if I shutdown the printer restart it and press print on my access program, it will printout blank sticker "nothing printed on them"

to make the printer print the sticker with the string on them again, I have to first do a print with another program "Barre One" then it will work with my access program.

any clue on how to resolve this error,

btw Im working with the old access 97
0
 
LVL 3

Expert Comment

by:QJohnson
ID: 8169559
What information do you want to print on the sticker?  I don't see the problem here.

You know WHAT to print right?  You only want to know how to print it.

Perhaps your variable, Data1, isn't in scope in the click routine of the button in your access program?

Hard to say from here.  Please tell me enough more to be able to provide some more focused assistance.  

0
 

Author Comment

by:PetitSinge
ID: 8169795
I know what to print, and it does print.

The thing is that let say I shutdown the printer.
Then I put it back on.

If I want to print a sticker it will just move out the number of sticker nothing will be printed on them "like the feed option".
Now if I print a sticker with another program "Bar One" and that I use my access program after it will printout the sticker with the string appearing on it.

before using "Bar One" nothing appears on them after the information is written.

here is the code I used to do the print "it's in ZPL II language and I have to send it to the printer."

    Data1 = "^XA^MCY^XZ" & _
    "^XA^LRN^FWN^CFD,24^LH0,0^CI0^PRA^POI^PMN" & _
    "^XZ^XA FT113" & _
    "^FO89,20^A0N,25,20 ^FDWaranty void if removed^1,1^FS" & _
    "^FO93,45^A0N,25,18^FDGarantie Annule si enleve^1,1^FS" & _
    "^FO117,75^AB^FD" & SNum & "^1,1^FS" & _
    "^PQ3,0,1,Y^XZ"

    Open "LPT1:" For Output As #1
   Print #1, Data1
    Close #1

basically the first part is the command and the second is to send the string to the printer.

p.s: I know that this code is working as it print me the stickers. the thing is that I have to first open and use another program to make it work.

The other program is not very efficient and user friendly that's why I created my own in access so that the non-experienced user can print the stickers.

I am sorry if I wasn't clear, Thank you very much for your help QJohnson  
0
 

Author Comment

by:PetitSinge
ID: 8169845
Somebody told me that it might be the driver issue "need to load it from access"

about
Printer.Print ...
Printer.EndDoc

I got the following error: Compile error, Method or data member not found it must be because of the version of access. I use 97
0
 
LVL 3

Expert Comment

by:QJohnson
ID: 8169931
You're right.  I can't find the Printer object in A97, either.  Apparently it isn't supported by VBA.  I am sorry to have led you in that direction.  I thought almost all of my VB runtime functionality was available in VBA by now.

Without knowing more about how your program and the BarreOne program interact, I'm really at a loss.

But if the requirement is to print strings on a sheet of lables, that interaction shouldn't really matter too much.

You should be able to store as many of the strings as you need and just print them when you're ready with a label report in Access, shouldn't you?

Or is there other information that needs to be merged onto the printed label that you have to deal with?
0
 

Author Comment

by:PetitSinge
ID: 8170536
that's what I tought but the thing is that the printer "Brady 200 MVP" is not a "normal printer" this one is made for the purpose of printing labels " I think it may cost over $10,000" with a normal printer I wouldn't have any problem printing but this one is special I guess.

as I said as soon as I print a single label with the other program, then I can print with my access program.

my supervisor told me something about them using a special set of instruction for their printer which is my problem I guess.

Can't count on the support line, I code for two days in this langague and I sure could teach them so much thing :(
and they dont have any forum on their webpage, only a KnowledgeBase.
0
 

Author Comment

by:PetitSinge
ID: 8170548
that's what I tought but the thing is that the printer "Brady 200 MVP" is not a "normal printer" this one is made for the purpose of printing labels " I think it may cost over $10,000" with a normal printer I wouldn't have any problem printing but this one is special I guess.

as I said as soon as I print a single label with the other program, then I can print with my access program.

my supervisor told me something about them using a special set of instruction for their printer which is my problem I guess.

Can't count on the support line, I code for two days in this langague and I sure could teach them so much thing :(
and they dont have any forum on their webpage, only a KnowledgeBase.

tnx anyway QJohnson

If by any change you find something about my problem I would really appreciate

If I don't have any answer tomorrow U will get the points.
0
 
LVL 3

Expert Comment

by:QJohnson
ID: 8170678
Is only your first label blank when you use your program or are they all blank unless the MVP printer prints one first?

If only your FIRST one is blank, you could just send it one at start up time so the REAL first one would print.  Likely you would have thought of that already though, I guess.

Did the printer come with any printed documentation that might be hidden away in a cabinet in your company's MIS shop?  There might be something useful in it.  Stranger things have happened.  <big grin>

Q
0
 

Author Comment

by:PetitSinge
ID: 8171141
question 1 nop all of them are blank "unless I print one with the other program before using access"

Question 2 There was no such programming guide or something with it but on their website I found some Exercise Book which helped me to create mine "there was full example from begining to end and each line were explained" but still I have no clue about my problem

about the fact that this happen, I think that Bradys did that on purpose so that we use their tool to print with their printer and I must miss only on single line of command but I cannot find it anywhere, not even on the next.

must be rated Classified or something
0
 

Author Comment

by:PetitSinge
ID: 8174015
I finally got found the answer to my problem "it was so obvious I tought it couldn't be that"

I had to set the label home position and the label length

Ive try it now and it work fine "unplugged the printer for 30sec then plugged it back"

**    Data1 = "^XA^LH0,0^LL113" & _ **
    "^FO15,10^A0N,25,18 ^FDWaranty void if removed^1,1^FS" & _
    "^FO19,35^A0N,24,17^FDGarantie annule si enleve^1,1^FS" & _
    "^FO38,68^ABN,20,^FD" & SNum & "^1,1^FS" & _
    "^PQ3,0,1,Y^XZ"
   
    Open "LPT1:" For Output As #1
    Print #1, Data1
    Close #1

the LH0,0 is the home position and the LL113 the size of the label in points.

tnx for your help QJohnson and as promess I will give you the points
0
 
LVL 3

Expert Comment

by:QJohnson
ID: 8174451
You are quite grateful and I thank you.

If you reconsider and decide NOT to award points, you are well within your rights.  All I did was really provide some companionship while you found your own solution.  If you need to keep points for other questions, I will understand.

Good luck, my friend.
0
 

Author Comment

by:PetitSinge
ID: 8175879
no its allright QJohnson

you were very helpfull because by explaining you my problem I did understood it better.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question