Shangrilla-
Here goes. Please keep in mind that there are many ways to accomplish this. Smarter guys than I may enter the net on this. This one will work and gives you something to work from towards a more suitable option for your application. A starting point if you will.
From above:
You have Used Customer.Dbf or some file. Created a quick report or some other report. Created a UDF() WhichPage.Prg that returns _pageno. Dropped that UDF() on the reports heading somewhere and right mouse Properties, Print When, _pageno = 0 in Print only when expression is true dialog box to make sure the value returned by Whichpage does not display when the report is previewed and or printed. All done then to the form.
Create New Form.
Place two command buttons on the form. From properties sheet Command1 Caption = \<Print, Name = cmdPrint. Command2 Caption = Pre\<view, Name = cmdPreview.
Click on the cmdPrint button and in the click event enter:
**** We only want one page to print, the last page the user **** previewed. We will use the RANGE startpage, endpage **** option in the REPORT FORM command. If the last page **** previewed was 5 (_Pageno = 5). Therefore RANGE
**** _pageno,_Pageno translates to RANGE 5,5.
REPORT FORM C:\AAATEST\Reports\TestPageNo.Frx RANGE _pageno,_pageno TO PRINTER
Click on the cmdPreview button or from the Object ComboBox and in the click event enter:
REPORT FORM C:\AAATEST\Reports\TestPageNo.Frx PREVIEW
The other shoe drops. What if the user selected Print without a Preview? No _pageno! Make sure _pageno is reset upon form entry or calling program.
Numerous ways to go here. Maybe wrap the print option within an IF ENDIF. IF _pageno does not return a positive value MESSAGEBOX("You must ....)
ENDIF or disable the Print option if _Pageno < 1, or whatever.
If you have further problems I could send you the form, etc..
Now I've demonstrated why I don't write "how to" stuff.
Roll on brother.
Jack
On to the Unix