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

Is the report sent to printer or just previewed?

Status
Not open for further replies.

vgulielmus

Programmer
Jan 27, 2014
522
RO
SYS(2040) returns "1" if a report is previewed and "2" if it's printed.
For using that value in the calling procedure, first a PUBLIC variable must be declared and set its value to "0"

Then put _vfp.setvar("gcReportDest",sys(2040)) in one of the report events, preferably Page Footer's On Exit

If the report is sent to printer (REPORT FORM ... TO PRINTER), the value returned is "2"
If the report is previewed (REPORT FORM ... PREVIEW) it behaves different under SET REPORTBEHAVIOR 80 and SET REPORTBEHAVIOR 90.
If SET REPORTBEHAVIOR 80 returns "1" if the preview window is closed without sending the report to printer, and "2" if the report is printed (the print button is clicked).
If SET REPORTBEHAVIOR 90 always returns "1" (because pages are printed from the cache).

Code:
PUBLIC gcReportDest
*********
CREATE CURSOR aa (aa I AUTOINC)
APPEND BLANK
******* Create a report and set the Page Footer's On Exit
CREATE REPORT aa FROM aa
SELECT 0
USE aa.frx
LOCATE FOR ObjType=9 AND ObjCode=7
IF FOUND()
	REPLACE TAG2 WITH '_vfp.setvar("gcReportDest",sys(2040))' && Page Footer, On Exit
ENDIF
USE
SELECT aa 
*********** SET REPORTBEHAVIOR 80
SET REPORTBEHAVIOR 80
gcReportDest="0"
REPORT FORM aa PREVIEW
DO CASE
CASE gcReportDest="1"
	MESSAGEBOX("Report was not sent to printer")
CASE gcReportDest="2"
	MESSAGEBOX("Report sent to printer")
OTHERWISE
	MESSAGEBOX("Report missbehaves")
ENDCASE
******** SET REPORTBEHAVIOR 90 preview
SET REPORTBEHAVIOR 90
gcReportDest="0"
REPORT FORM aa PREVIEW 
DO CASE
CASE gcReportDest="1"
	MESSAGEBOX("Report was not sent to printer")
CASE gcReportDest="2"
	MESSAGEBOX("Report sent to printer")
OTHERWISE
	MESSAGEBOX("Report missbehaves")
ENDCASE
*********** SET REPORTBEHAVIOR 90 to printer
gcReportDest="0"
REPORT FORM aa TO PRINTER
DO CASE
CASE gcReportDest="1"
	MESSAGEBOX("Report was not sent to printer")
CASE gcReportDest="2"
	MESSAGEBOX("Report sent to printer")
OTHERWISE
	MESSAGEBOX("Report missbehaves")
ENDCASE

My respects,
Vilhelm-Ion Praisach
Resita, Romania
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top