Global Declarations
Hi.
All calculated and assigned values in all Global Variables clears after
printer change.
I can see value on preview but not prints.const same too.(V9.03)
In this example variable6 never prints if printer has changed.
Prints correctly when printing to default printer.
Preview screen values are always correct.
global variables
var str: string;
procedure ReportBeforeprint;
begin
if Report.DeviceType='Screen' then
str := MyFunc;//
//myfunc must be run only once and value must be saved for printing.
sometimes this event fires two times
end;
procedure variable6onCals(var value:variant);
begin
Value := Str;
end;
Thanks.
All calculated and assigned values in all Global Variables clears after
printer change.
I can see value on preview but not prints.const same too.(V9.03)
In this example variable6 never prints if printer has changed.
Prints correctly when printing to default printer.
Preview screen values are always correct.
global variables
var str: string;
procedure ReportBeforeprint;
begin
if Report.DeviceType='Screen' then
str := MyFunc;//
//myfunc must be run only once and value must be saved for printing.
sometimes this event fires two times
end;
procedure variable6onCals(var value:variant);
begin
Value := Str;
end;
Thanks.
This discussion has been closed.
Comments
I'm a bit unclear about the full issue. Where are you assigning the global
variables? If it is inside the OnGlobalCreate event, they should never
loose their values unless it is changed in another event.
Instead of using the OnBeforePrint event, try using an earlier event such as
the OnBeforeOpenDataPipelines.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
values.Following are informal only.
Thank you.
procedure ReportBeforeprint;
begin
if Report.DeviceType='Screen' then
str := MyFunc;
end;
At design I put a variable and get value from global variable str.
I was using beforeprint to assign variables.I have no code in globaloncreate
etc;
After printer change event fires second time and my variables are empty ,
first time assigned values are lost.
I am checking if event is fired first time and then making assignments.
(Report.DeviceType='Screen' if first )
Event first fires at preview and then fires again when printing.
if NO printer change event fires once no problem.
I found that this occurs when not printing to the default printer. (maybe on
printer selection ?)
Tried two things to understand
1) At preview ReportBeforeprint event fires ,then I click "print" button
then change the default printer and select another printer then press ok to
print, ReportBeforeprint event fires second time and first values clears at
second time.
I put a "showmessage(Report.DeviceType)" In ReportBeforeprint it gives me
two message box :
First message : 'Screen', (variable ok)
second message :'Printer' (variable is empty)
2) I do not change the printer and print to the default printer
ReportBeforeprint event fires one time (only preview time) and variables are
ok
This time showmessage tells me Report.DeviceType='Screen' and only one time.
I use this code "if Report.DeviceType='Screen then str := MyFunc;' "
because I want to run Myfunc only once.