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!

Printing

Status
Not open for further replies.

ChrisAgius

Programmer
Sep 27, 2000
51
MT
I have this problem dealing with printing. I have two printers installed in the system . LaserJet HPLJ4 and a Star Matrix LC-15.

So when I try to print a report from my form the program uses the default Visual Foxpro Page Setting Size. But I want the to the default settings and page sizes from control panel as not to change the settings each time I change the printer.

This lead to the problem that when I choose a paper size A4 results that the setting is too big for the Star Printer and thus will continue printing on the next page. And when I choose letter to satisfy the Star Printer the output from the Laser Jet will be too small. (like too big empty header and footer)

Can Anyone tell what I can do ... if possible step by step. I am sure there is a solution out there and that someone can help with this problem. [sig][/sig]
 
ChrisAgius

There is no need for you to use control panel to select your printer

Open up your report in the report manager. Click on Page Setup and select the printer you require. Change the properties of the printer to the correct paper size, etc, and if necessary change the properties of the form to suit.

Click on Save As and save as Report1, but do not close the file.

Click on Page Setup and select the other printer you require. Change the properties of the printer to the correct paper size, etc, and if necessary change the properties of the form to suit.

Click on Save As, save as Report2 and close the report.

Now you have 2 reports, each with a different printer driver.

Insert the following code into your program:-

lcAlias = ALIAS()
lcPrinterName = GETPRINTER()

IF lcPrinterName = [LaserJet HPLJ4]
[tab]USE report1.frx IN 0 ALIAS TEMPREPO
[tab]SELE TEMPREPO
[tab]GO TOP
[tab]REPLACE TEMPREPO.Expr WITH [ORIENTATION=0] ,;
[tab][tab]TEMPREPO.tag WITH [] ,;
[tab][tab]TEMPREPO.tag2 WITH []
[tab]REPORT FORM report1.frx NEXT 1 TO PRINTER NOCONSOLE
ELSE
[tab]USE report2.frx IN 0 ALIAS TEMPREPO
[tab]SELE TEMPREPO
[tab]GO TOP
[tab]REPLACE TEMPREPO.Expr WITH [ORIENTATION=0] ,;
[tab][tab]TEMPREPO.tag WITH [] ,;
[tab][tab]TEMPREPO.tag2 WITH []
[tab]REPORT FORM report2.frx NEXT 1 TO PRINTER NOCONSOLE
ENDIF

USE

SELE (lcAlias)

****

What is happening is that GETPRINTER() will select the printer for you.

You are then opening the report as a table and removing the printer driver information, which is then replaced with the correct printer driver information when you run the report.

Chris





[sig][/sig]
 
It is ok to a small number of reports but if I have 300 reports, it is not worthed to duplicate the reports. That is why I need to find a setting for the page setup. [sig][/sig]
 
ChrisAgius

It is ok to a small number of reports but if I have 300 reports.

Do you mean by this you will be printing the same report, but from 300 different records, or will you, as a programmer, be creating 300 different reports for the project?

If you are using the same report for 300 different records, then you need to change the NEXT 1 code in the command line to ALL, NEXT nRecords or a FOR ... expression.

Chris [sig][/sig]
 
ChrisAgius

Could you explain some of the differences between these reports?

There may be a way to make changes within the report, rather than create 300 different versions.

Chris [sig][/sig]
 
Assuming you have a report xxxx
drop to dos and make a back up copy of the report
copy xxxx.* yyyy.*

then go back to VFP and try this
close data
use xxxx.frx
locate for OBJTYPE =1 and OBJCODE=53
replace TAG with ""
replace TAG2 with ""
replace EXPR with ""
use
use dbfs for the report
report from xxxx to print

These fields in the FRX file hold printer definition and setup info. This will force FoxPro to use the setting of the default printer.
[sig]<p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br>[/sig]
 
1. are you sure you closed the frx file. This is a common error if the frx is open when someone tries to use it.

2. trap the error with a
on error **
and see if it prints

3. Try keeping the info in the EXPR field. [sig]<p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top