SYS(2040) is very useful, but its value is relevant only inside the report. So SYS(2040) will be saved into a private or public memory variable, from one of the Summary band events, or Page footer band events.
Example: at ON Entry in the Page Footer Band, place :
_vfp.setvar("MyFlag",sys(2040))where MyFlag is a private or a public variable
In the calling procedure / method:
PUBLIC MyFlag MyFlag="0" REPORT FORM ... DO CASE CASE MyFlag="1" MESSAGEBOX("Report is in Preview Mode") CASE MyFlag="2" MESSAGEBOX("Report is being sent as output (such as a printer or file).") ENDCASE