Send a String to a printer

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.

PetitSingeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

QJohnsonCommented:
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
PetitSingeAuthor Commented:
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
PetitSingeAuthor Commented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

PetitSingeAuthor Commented:
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
QJohnsonCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PetitSingeAuthor Commented:
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
QJohnsonCommented:
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
PetitSingeAuthor Commented:
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
PetitSingeAuthor Commented:
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
QJohnsonCommented:
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
PetitSingeAuthor Commented:
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
PetitSingeAuthor Commented:
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
QJohnsonCommented:
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
PetitSingeAuthor Commented:
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
PetitSingeAuthor Commented:
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
QJohnsonCommented:
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
PetitSingeAuthor Commented:
no its allright QJohnson

you were very helpfull because by explaining you my problem I did understood it better.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.