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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SET PRINTER TO NAME Not working

Status
Not open for further replies.

TGrahmann

Programmer
Feb 19, 2015
43
US
Hello, all. I am having an issue with the SET PRINTER TO NAME [Windows Printer Name] command. I do not receive an error, but when I issue the command, then try to do a REPORT FORM frmTest TO PRINTER, It automatically is sent to my default printer. Any help is greatly appreciated!
 
I use a variation on this:
Code:
IF !EMPTY(m.PRINTERNAME)
	IF m.PRINTERNAME <> "DEFAULT"
		SET PRINTER TO NAME (m.PRINTERNAME)
	ELSE
		*SET PRINTER TO DEFAULT
	ENDIF
ENDIF

Where m.PRINTERNAME is often selected using GETPRINTER()

Note the use of a character expansion - which might be where you are getting difficulties.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
This is a very common problem. It comes about when VFP stores information about a particular printer in the report itself (the FRX file). When that happens, no matter what printer you select, the output always goes to the one stored in the file.

If you have VFP 9.0, the solution is simple. Open the report in the report designer, and un-tick "Printer Environment" in the Report menu. Then save the report.

If you have an earlier version of VFP, you can solve the problem by manually editing the FRX, which is a little more complicated. For further information, see Controlling report settings at run time.

There's also some information here: Trouble-shooting a Visual FoxPro application, under the heading "Problem #5: Printed output goes to the wrong printer".

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike's right on this, I have a routine, running since VFP3 I think, that I run before each compile that takes MOST of the printer data out of the frx, so I never think about it.

I leave page size, orientation, duplex settings, resolution I fix at 300 (don't remember why) and I seem to set the papersource to 7(?) and remove the rest.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
I seem to set the papersource to 7(?) and remove the rest

Griff, setting the papersource to 7 simply means "automatic feed" - which would usually be the default for a given printer.

If you want a full list of all the possible settings for the paper source, see the VFP Help page for the PRTINFO() function.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks, guys. I wasn't aware of the "Save Printer Environment" issue. However, there are a couple forms that I need printed portrait and another couple I need printed landscape. Is there a way to set this programmatically at runtime?
 
You shouldn't need to set the orientation programmatically. You can set it in the report designer. Go to File / Page Setup / Page Layout / Page Setup.

The orientation will be saved with the report, but - provided you have un-ticked Printer Environment - the destination printer won't be.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Page orientation is something you could keep in the memo field of the frx containing such settings, but to be truly independent of printer choice the solution is to have a logical printer (inatall printers multiple times with different names) and make such orientation settings per name.

Besides most printers will recognize how to orientate the print output so it fills the page.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top