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 Form2 onto Back of Form1, Conditionally

Status
Not open for further replies.

stanlyn

Programmer
Sep 3, 2003
945
US
Hi,

I've to do something here that is a first for me... I'm using VFP9sp2.

Our Marriage License app that been working flawlessly for years now, and now I must update the app due to the new "same sex" laws that has just been enacted...

What I want to include in my update is printing form1 (as usual) onto the front of the blank perforated form, plus conditionally print the "Marriage Consent Form" on the back if applicant(s) are under 18 years old. If both bride and groom, (now its "Party1" and "Party2") are under aged, then I need to print one for each of them on the back of the license. Everything, (license and consents) are contained on a single sheet of paper, (the license).

I know that VFP9sp2 is capable, but frankly I dread working with its advanced "reportbehavior 90" features like chaining and etc. I've always had to fight it in the past. I also have all of Cathy's articles and books covering its usage, and I still dread tackling this, but I will...

So, any pointers on "how you would you do this" would be greatly appreciated.

Thanks,
Stanley




 
Stanley,

Can we assume that the user has a duplex printer (one that is physically capable of printing on both sides of a sheet)?

If so, it's not at all difficult. When you need to print a double-sided sheet, print your first page as usual, but include the keyword NOPAGEEJECT in the REPORT FORM command. Then print your second page as a separate report, without the NOPAGEEJECT.

If I've understood your question right, that's all you need to do.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

>> Can we assume...
YES

Can't wait to try... I hope its that easy and if so, I was really making it more complicated than necessary. I do remember the NoEject keyword, but have never used it...

Thanks,
Stanley
 
I do remember the NoEject keyword, but have never used it...

Take care. NOEJECT is not the same as NOPAGEEJECT.

NOEJECT is a hangover from DOS. It is still allowed, but it doesn't do anything. NOPAGEEJECT is the one you want.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

NOT working for me...

I created a test program as help about the NoPageEject" clause says you cannot test it in the command window. So, I created a .prg and 2 forms, one with a label "Form 1" and the other with a label "Form 2"

When run, it immediately prints the first page with the label "Form 1" and then previews the 2nd form containing "Form 2". Form 1 is in the printer tray while previewing the second form.

Here is the program...


Code:
Cd "d:\licgen\licgen_2015\"
If !Used('preference')
	Use licgen!Preference In 0 shared
Endif

Select 'preference'
Go Top
Report Form .\reports\report1.frx Record 1 To Printer Nopageeject
Report Form .\reports\report2.frx Record 1 To Printer Preview

Thanks,
Stanley

 
Hi Mike,

Same results, except it doesn't preview. I get Report1 on one sheet of paper and Report2 on a second sheet. The reports are not saving the printer environments with them. The network duplex printer's driver on the host pc is configured with duplex=on.

It appears the "Nopageeject" is not working, because it immediately prints Report1 whether or not Report2 is being held up by a preview or allowed to print immediately without a preview.

I was expecting Report1 to process and not print anything until a) a timeout occurs, or b) a print command or job closes the job. What am I missing here?, (should be easy as you first suggested, but now we are here fighting it)...

ReportBehavior=90... if that matters...

Thanks for your interest and help,
Stanley

 
Stanley,

I've just run a quick test myself, similar to yours. It works fine for me.

This is my code:

Code:
REPORT FORM Test1 TO PRINTER PROMPT NOPAGEEJECT 
REPORT FORM Test2 TO PRINTER

Test1 and Test2 are both single-page reports. When the printer prompt appeared, I chose my HP 400 duplex printer. The reports printed as expected, back to back. I tested it with REPORTBEHAVIOR set to both 80 and 90.

The only reason I can think of that yours is not working is that you have selected the wrong printer, or the printer is not configured for duplex printing. You can check for that by printing any multi-page report to that printer; the report should come out double-sided.

Off hand I can't think of anything else.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
> The network duplex printer's driver on the host pc is configured with duplex=on.

That doesn't take effect, if your FRXes have other settings embedded. Take away the tick at "save printer environment" to let the printers own setting have effect.

The best thing you can do is install this network printer on the client again with a separate name you specify in the setuprocess. Give that seperate printer name the settings you want, then before printing
SET PRINTER TO NAME yourname

Then do the two REPORT FORM statements with reportds, which have no printer environment embedded.

Bye, Olaf.


 
The best thing you can do is install this network printer on the client again with a separate name you specify in the setuprocess.

Yes, I agree. That's what I would always do.

That's why I suggested testing it by printing any multi-page report to the printer in question, and checking that it comes out double-sided. If it doesn't, you are either seinding the report to the wrong printer driver, or the driver is not configured for duplex.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike and Olaf,

>> REPORT FORM Test1 TO PRINTER PROMPT NOPAGEEJECT

It doesn't make any sense that prompt is necessary... Mine is reliably sending the jobs to the pc's default printer as it should, because I did not change it via the 'prompt' keyword. This usage is why we have a 'default printer' assigned to a pc???

Why would it matter what printer is used as 'NOPAGEEJECT' should send the print job to ??some?? printer whether network or not and then wait for the 2nd print stream without the 'NOPAGEEJECT' that closes and finally prints the page to that ??some?? printer. That ??some?? printer is reflecting the client pc's default printer, the same one used when 'prompt' is not used to select/change it.

In my situation, when I run 'REPORT FORM Test1 TO PRINTER NOPAGEEJECT' without a prompt, it immediately prints a page and ejects it (not expected), to the pc's default printer (expected). The selection of printer should not matter as it is already selected by being the pc's "default printer" and that should be fine in the absence of the 'prompt' keyword.

I still have to test your suggestion as well as an the idea of maybe using a report's summary page to get the 2nd page that Tamar and Mike was discussing on tek-tips # thread184-1686674... (very interesting...)

Thanks, Stanley




 
Stanley,

By all means leave out the PROMPT clause. If you are sure that the duplex printer is the default printer, that's fine. I included the clause in my own tests simply to be sure I was sending the report to the correct destination.

That said, be clear that the report will go to the Foxpro default printer, not the Windows default printer. In other words, if you have executed SET PRINTER TO NAME .... in this session, that will be the printer that will print the report.

Also, be careful to distinguish printers and printer drivers. It is the driver that knows to do duplex printing. If the driver does not default to duplex, you will need to change its properties, or install a new instance of the driver.

This is why I am suggesting that you print a normal multi-page report - just to see if duplex printing works in your system. That will tell you whether the problem lies in the printer / driver or in the REPORT FORM command.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

>> just to see if duplex printing works in your system

Yes, I use it all the time, both from VFP and other Windows apps. My VFP apps that I'm using in duplex mode is doing a multi-page report, not chaining multiple reports into one. So, from this info, the printer and print drivers are OK??

You mention VFP and Windows printers... What is the difference? I don't ever remember setting up a VFP printer, only Window's printers. Again, I just looked at the options and see no reference of setting up a VFP specific printer. Only Windows printers and Windows drivers that VFP uses... I have many times used the "to printer name" clause for printing to a network printer that always passes thru a Windows printer and its driver on the local pc in route to the network printer.

Thanks,
Stanley
 
Stanley,

I wasn't referring to Windows printers or Foxpro printers. I was referring to Windows and Foxrpo default printers.

This simply means that the printer that VFP (or your VFP application) sees as the default printer is not necessarily the one that Windows sees. You can change the VFP default printer by using SET PRINTER TO NAME, but that does not change the Windows default printer. That's all I meant: no more, no less.

But the main point is that you have eliminated the printer or driver as the cause of your problem (at least, I think that's what you're saying).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Stanley, if you really can't get this to work using NOPAGEEJECT, it might be worth following up Tamar's suggestion (in the other thread you referenced).

Essentially, you create the whole of the second report as the summary band of the first report. I don't know if that would be possible in this case. I'm assuming that the second report contains no repeating data; in other words, that it doesn't require a pass of the underlying cursor to produce the data, but just contains constant values or summary data.

If that is the case, you only need to tick "Summary prints as new page" in the Optional Bands tab of the report properties. You will then be able to print the whole job with a single REPORT FORM - using your duplex printer driver, of course.

I don't particularly like suggesting you use this solution. I would rather find out why NOPAGEEJECT does not work for you. But I realise you need a solution, and this one is at least worth considering.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Just one thing to notice: NOPAGEEJECT does not work from the command line, only from within a PRG.

The "magic" behind it is it leaves a windows print job open and adds the next report to it. If there is something not working with the Windows printer jobs in conjunction with your driver NOPAGEEJECT may also not work because of that.

Bye, Olaf.
 
Hi Mike & Olaf,

I actually done what I needed via Tamar's "summary page" as the repeating values I needed was already alive from the 1st run of the print job. It works perfectly...

For the non-summary way via chaining, I was able to get report2 onto the back of report1, but only if the 2 report commands were run quickly. For example, if I issue "report ....... NopageEject", it would not wait, instead it physically printed it, (which is not what I was expecting. I expected it to wait until another print job closed it, or a timeout occurred.

So once again, another 3-4 day fight where I eventually abandoned it for a simpler solution that worked as expected... Which begs a question of "Is others having these sort of issues with the 90 printing behaviors, or is it just me? Somehow, I feel that the assisted 90 report behaviors was not fully tested and ready for prime time when it was released and then the whole VFP thing got cancelled. As I stated in my opening question, "I dreaded tackling this..."

And Olaf, I too saw help's mention that it cannot be tested via a command line, so that is why I put all my tests in a prg. I mentioned that at the top of a post early on.

Anyway, problem solved, with a lot of practice of "trying to make assisted 90 work". I did learn a lot and am better for it.

Thanks Mike and Olaf,
Stanley
 
Well, also normal print jobs start printing before they are closed, so the first report starting to print immediately is not unexpected.

I don't know all your settings, but testing a combination of 2 simple reports page1.frx and page2.frx to my default printer in duplex mode does not have the problem of printing on two separate sheets.
My printer driver offers a preview itself, which gets shown after a print job finishes, and my two FRXes show as one preview, one sheet with 2 pages.

My two sample reports actually don't print anything in their detail band, but only have a label in header/footer area. To print, they still have to find a report driving cursor not at EOF, so I create a dummy cursor and add a record to it.

I just have another problem: The second report just generates an empty sheet. And I haven't forgotten to go top in the dummy report cursor before starting the second FRX.
So that's a bit of a mystery, but the chaining into one print job obviously works, two pages are shown in the preview of my printer driver with this code:

Code:
Create Cursor curReportDummy (f1 c(1))
Append Blank 
Set ReportBehavior 90
Report Form page1 To Printer NoPageEject
Go Top in curReportDummy 
Report Form page2 To Printer

Bye, Olaf.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top