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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determining if "print" or "close" was chosen from Print Prev

Status
Not open for further replies.

waynebrady

Programmer
Feb 20, 2003
24
US
I'm trying to find out if there is a way to determine if a user has clicked Print or Close from the report writers preview screen. I have a form that the user indicates how many copies of a report they would like printed. If the user selects more than 1 copy and preview is also "checked", I would like to preview only the first copy, wait for the user to determine its correctness and either let them print the rest without preview or terminate the additional report cycles. If I could capture which icon was chosen then I could continue on not.

Any thoughts?

Thanks

Wayne Brady
 
Wayne,
A quick excerpt from "The Visual FoxPro© Report Writer: Pushing it to the Limit and Beyond" By Cathy Pountney - available at While it's not exactly what you asked for, you should be able to adapt the idea.

"How do I know if the user canceled?

Often, you need to update some type of printed flag in the data or do some special processing once the user has printed a particular report. To accomplish this, you need to make sure the user really did print the report. You wouldn’t want to update the flag if the user only previewed the report. In addition, you need to make sure the user didn’t cancel the report before it finished.

To solve this problem, use the following code to call the report.
Code:
*-- Initialize variable
PRIVATE plPrinted
plPrinted = .f.
*-- Print the report
REPORT FORM MyReport NOCONSOLE TO PRINTER PROMPT PREVIEW
*-- Check to see if the user printed
IF plPrinted
* Do your update code here
ENDIF
*-- Get out
RETURN
*----------------
FUNCTION Rpt_Done
*----------------
*-- Set the printed flag
IF WEXIST("Printing...")
   plPrinted = .t.
ENDIF
As the final step, use the following expression in the On Exit portion of the Summary band.
Rpt_Done()

Because the Summary band is the last thing processed by the Report Writer, calling the UDF in the On Exit section of the Summary band ensures the plPrinted flag isn’t set until the entire report has finished. Of course, you can’t be sure it physically printed, but that’s out of your control.

In FoxPro 2.x, the name of the Preview window is “Page Preview” instead of “Printing…”."

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top