OK, the part about showing the logo on condition to preview and not when printing makes it even a bit more complicated, as you also need to react to the current report mode SYS(2040) to decide for Preview or Output. You also need to know whther output is to PDF or printer.
So let me comment on Mikes instructions:
>1. In the report designer, place a new image in the report, and open its Properties dialogue.
As you most certainly already have an image in your report, you get to it's properties by right clickinng on it and starting properites from the context menu.
In general, if you want to find out about something, many things in VFP have context menu, so remember there is a right mouse button.
>2. In the General tab, choose "Expression or variable name"
...as the Control source type. That enables you to dynamically define the file name via a variable or a field in your report table.
>3. For the control source, enter an expression similar to this one: IIF(FILE("MyFile"), "MyFile", "")
In that case no variable, Mike simply distinguishes the cases the file is there or not. MyFile obviously needs to be the fll pathname to a file. You might take that from some configuration, you have to know the file location of a logo. For not printing a logo an empty gif or jpg is a better choice than just no file name, to avoid the piompt for a file, but Mike typically is right, so I expect a "" would work for no logo, too.
>4. On the Print When tab, enter an expression like this one: FILE("MyFile"))
The "Print When" tab is the second tab of the properties dialog you opened in step 1. The condition could also include reacting to SYS(2040) and you may predefine if a PDF is generated or the report is printed to paper with corporate logo already preexisting in a variable llPrintLogo you eitheer set .T. or .F.
All variables you have defined in the same code you start the report via REPORT FORM can be used in the report in such expressions. So you might also set a variable lcLogoFilename and set it to either the logo or an empty JPG beforehand. The PrintWhen will still be useful to add the logo in preview mode, so in general if there is a file you should specify it and then decide whether to print or not depending on the mode and destination you might "pass in" into the report by defining variables the report can evaluate. As simple as that, we don't need to switch to a Reportlistener class or put some info into the data reported to let a report see it.
So call your report this way:
Code:
LOCAL llPrintLogo, lcLogoFilename
lcLogoFilename = file name of either logo or an empty jpg
llPrintLogo = NOT <<condition to print to pdf>>
REPORT FORM ....
In the image control the
Control Source type then will need to be
Expression or variable name, as Mike suggests, and the
Control Source then simply is
lcLogoFilename. In the print when tab you set the
Print only when expression is true expression to
(llPrintLogo OR SYS(2040)="1") AND FILE(lcLogoFilename).
Bye, Olaf.