Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Choosing a printer at run report time 3

Status
Not open for further replies.

JoeyDC

Programmer
Mar 24, 2013
18
US
thread184-1691596
I'm new to this forum so I have been reading a lot of older posts. I came across
thread184-1691596. The gist of the responses was that you should virtually never hard code a printer choice in your code, but allow the user to make the choice. I understood the discussion about the printer being specified in the FRX/FRT files and about how to get rid of that, etc. Everyone seemed to agree that using "SET PRINTER TO <desirable_printer>" before printing was to way to go.

This question may be out of line, but here it is. Why not just code "REPORT FORM <myreport.frx> TO PRINTER PROMPT"? It works form me even when a printer in embedded in the report file. Am I missing something?

Thanks -- Joey
 
Well, a user wouldn't want to choose a printer everytime he prints a report. SET PRINTER TO NAME (GETPRINTER()) is something you can do and then print any report to that printer. Also, you may not want a choice from all printers in a network of a larger company.

Bye, Olaf.
 
Welcome to the forum, Joey.

Just to add to Olaf's answer ... In fact, it's fairly common to use REPORT FORM <myreport.frx> TO PRINTER PROMPT. Many programmers use that rather than selecting the printer first with SET PRINTER TO. If you've done that yourself and your're happy that it works, you should carry on doing so.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Ah, wait. I might have misunderstood your question. I think you are asking why it's necessary to avoid hard-coding the printer, when you can use the TO PROMPT clause to override it at run-time.

Apart from what Olaf said about not wanting to make the choice every time, I can only think that it's considered bad practice to hard-code the printer. It means that you always have to be sure to include the clause every time you issue the REPORT FORM command, and you might one day forget to do so. Also, if the user initiates a print by clicking the Print button in the report preview toolbar, you won't have the opportunity of doing the prompt.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Mike, your first reply was correct, and I totally understand about hard-coding.

Olaf, thanks for your incite. Since I'm not on a network myself, I don't know all the "ins" and "outs" of the problems associated with one. Your solution does seem likely to be more appropriate if one is on a network.
 
Also, you can display the currently selected printer - SET("PRINTER",3). I sometimes display it near the print button or put that in a ToolTipText property so the user can hover and see the current setting displayed.

? SET("PRINTER") && ON | OFF
? SET("PRINTER",3) && FileName or PortName
? SET("PRINTER",2) && Default Windows printer name
? SET("PRINTER",3) && Current Visual FoxPro printer name
 
Correction:
? SET("PRINTER",1) && FileName or PortName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top