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!

PRINT PREVIEW 1

Status
Not open for further replies.

shangrilla

Programmer
Nov 21, 2001
360
0
0
US
how can I print the current page from the print preview window. Is there anyway you can change the code behind the 'print' button on the 'print preview' toolbar.

Thanks

 
Try adding "TO PRINTER PROMPT" behind the line of code that executes your print command. The PROMPT command will generate your Windows print dialog box so you can select a different printer or put in a page range.

REPORT FORM FileName1 TO PRINTER PROMPT

Good luck
 
I am aware of this, but I don't want the users to go and enter the page #. I want just current page printed without entering any page rage. Has Anyone done anything similar to this before. Also I want to change the code behind the print preview toolbar or may be add a new Button to it.
 
Shangrilla-

If you haven't done so and I understand; you may want to look at range where your report contains the expression _pageno which I'm sure you have on your reports. Numerous ways to go from here.

I remove the Printer Option from the Print Preview Toolbar (lots of Threads on this subject here), and put click stuff as below under a separate cmdPrint button. Then users can Preview and or Print. If printing it would fall to your what you wish to scope.

nStartpage = 1
nendpage = 1

REPORT FORM C:\AAATest\Reports\TestPageno RANGE nStartpage,nEndpage NOCONSOLE TO PRINTER

Hope this helps,

Jack
Rainy Georgia
 
Shangrilla-

I didn't complete my thoughts in my post above. Sorry.

Obviously one needs to capture _pageno of the last page the user previewed. Somehow we must be able to set a variable
in the report, capture it then do a range print.

Will work on it when I get back from work.

Jack
 
Shangrilla-

Think maybe this is what you wanted or at least will give the direction to get there.

Task was to identify the last page number the user was previewing when the preview window/toolbar was closed.

***************

I created a UDF.

* WhichPage.Prg

Return _pageno

****************

Created a Quick report from Customer.Dbf

Copied the textbox for _pageno. Pasted and edited to change to WhichPage(). Right Mouse on WhichPage() textbox, Properties, Print When, _pageno = 0 in Print only when expression is true dialog box.

*****************

Created TestPageNo.Prg

* TestPageNo.Prg

REPORT FORM C:\AAATest\Reports\TestPageNo.Frx Preview

?_PageNo

Return

**********************

Taking the printer option off your print preview toolbar and creating a cmdPrint button using the _pageno value should work.

I'm sure that there are probably many more elegant ways to do it and lots of guys to tell you how.

Tested and proper _pageno was returned.

Might even add it to my tool box.

Jack
 
Hi Jack:

Thanks for taking interest in my problem. How can I add a new cmd Button on the print preview toolbar. I know this much: View --> Toolbars --> Customize --> Print Preview.

After I remove the print button from the toolbar it just creates a new toolbar. It still shows on the Print Preview toolbar. I really don't have to remove the print button, but I want to test this by adding a new cmd. button. I am just confused where do I create that cmd. button etc and add it to the print preview toolbar.

I appreciate you help.
 
Shangrilla-

First to thank you.

Will get back soonest after I try to figure out some Unix stuff of which I know nothing.

Jack
Still Cold in Georgia
 
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(&quot;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 &quot;how to&quot; stuff.

Roll on brother.

Jack
On to the Unix




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top