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!

it is possible to print, to an specific tray ,based on an specified value from a table.field 2

Status
Not open for further replies.
Jan 20, 2007
237
US
Hi Everyone
i need to print invoices on the same printer, of course this printer has up to 3 trays, one of them have blue paper, there is field named "terms" in the table that, if table.terms ="30 days" i would like this invoices with these value to be printed to the tray with blue color paper and if not will print to the default tray, how in vfp 9.0 can i accomplish it ?
can anyone guide please ?
Thanks so much in advance
 
The easiest solution is to define more than one "virtual printer" to the same physical printer. IOW install the printer twice, using different names, and with different printer properties. You then simply have different "Set Printer to Name xxxx" clauses, depending on the field you mention.
 
Alternativel:

1. Create two copies of the report.

2. In each case, in the Report Designer, go to the Page Setup dialoge. Select the target printer.

3. In the same dialogue, click the Page Setup button. In the resulting dialogue, set the Source to the relevant tray. (This will be different for each of the two reports.)

4. In both cases, make sure Printer Environmen is ticked (in the Report menu).

5. Save each report under an appropriate name (e.g. Invoices_White and Invoices_Blue). When you are ready to print the invoices, issue a REPORT FORM command for the appropriate report.

The disadvantage of this method is that, if you later need to change the invoices, you will have to apply the change to both copies.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I second what Tore says, but that also means you have no chance to change tray within a report, not even per page.

You will have to run single page reports and for each one set the corresponding logical (virtual) printer, but that is possible.

You don't need N DBFs for that, you can run a report FOR NEXT 1, only printing one record. Or you query what belongs into which try into separate DBFs or cursors in advance.

Besides that, I know print stations which have 10 trays and have modes in which pages are sorted into the several trays one after the other and further modes, something you could configure without VFP doing anything specific to get there, that's done by the print station configuration.

Bye, Olaf.



Olaf Doschke Software Engineering
 
The disadvantage of this method is that, if you later need to change the invoices, you will have to apply the change to both copies.

So here is another solution that doesn't have that disadvantage:

1. Create a single copy of the report, as usual.

2. Set the source to the white paper tray, as described above.

3. Make sure Printer Environment is ticked (in the Report menu).

4. Before printing the report, open the report as a DBF and programmatically modify the Expr field, so that DEFAULTSOURCE points to the relevant tray. Then close the DBF and go ahead and print the report.

Step 4 is a little complicated. Rather than my explaining it in detail, have a look at Controlling report settings at run time, which gives an example of the code you need and explains how to get the values for the different paper trays.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Ok, let me clarify something here.

SBT pro 5.0 it is an application done in vfp 5.0, so there are already a report form to print invoices and of course the data that will print in that report form comes from a cursor, the problem is or the question is IF fieldname "TERMS" value='30 DAYS' then i need that invoice to print in a different tray, probably the next invoice to be printed the value of "TERMS' IS EMPTY so then this should go to the default tray most likely white paper tray.
i just saying this to make sure i explained this correctly and the answers are based on what i am saying here, sorry if i explained correctly. so would this change your suggestions ?

i guess i will have to change something in the source code to reroute when TERMS='30 DAYS' to a different printer or if it possible programmatically get the tray number on the same printer when the value is as mentioned
 
As already said you can't change tray based on data within a running report, you have to do this from the outside.
Unless a printer automatically uses multiple trays you can only pick one tray before starting the report.

So if you print invoices as one report that spans multiple invoices and you want to react when the group = invoice number changes, you cann't switch trays.

You instead need to have printerdefault and printerspecialtray and then print single invoices this way:

Code:
SELECT invoices
SCAN
   If invoice.TERMS='30 DAYS'
      SET PRINTER TO NAME printerspecialtray
   Else
      SET PRINTER TO NAME printerdefault
   Endif
   REPORT FORM yourreport.frx NEXT 1
ENDSCAN

As preparation, you install the printer twice once named printerdefault and once named printerspecialtray and configure them to the trays. That's something under control of the printer settings, not under control of VFP or VFPs reports and if so, you could only set this up for the whole report, not per page.

That means nothing changes with what I said, I only made more explicit what I meant.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top