I create a report with Variable1 (type Boolean) I saved this report and I load it dynamically. What's the way to modify the value of Variable1 before preview or printing ?
Nico Cizik (Digital Metaphors) a présenté l'énoncé suivant :
Yes that's that I use ! I have found an example in your tech tips news. To access a component, I use a loop and I test on component name
But my question is: Is it possible to access TppVariable and modify the value before printing ? I have tried with Parameters list but It seem that I can't change value of one variable ...
Sorry about that, I misunderstood the question. Parameters are probably the best way to go with this. The reason the TppVariable's value is not showing up is because ReportBuilder initialized all variable values before the report prints. When using parameters, you will need to update the TppVariable's value inside the OnCalc event to change it successfully.
Comments
I would suggest using one of the template events to do this. The OnLoadEnd
event should do the trick.
----------------------------------------------
Tech Tip: Using Template Events
----------------------------------------------
The Report.Template object has several events that can be used for
customizing what happens when a report is loaded or saved:
- OnLoadStart
- OnLoadEnd
- OnNew
- OnSaveStart
- OnSaveEnd
The OnLoadEnd and OnNew events are often used to perform actions related
to report and data initialization.
The OnSaveEnd event is often used to save additional descriptive
("meta") data to the database each time the report is saved.
Example:
The Report.Template events are public and therefore must be assigned at
run-time.
1. In the private section of your form declaration you can declare an
event-handler method:
TForm = class(TForm)
private
procedure myTemplateOnLoadEndEvent(Sender: TObject);
public
end;
2. In the Form.OnCreate event, you can assign the event-handler to the
event:
procedure TForm1.FormCreate(Sender: TObject);
begin
ppReport1.Template.OnLoadEnd := myTemplateOnLoadEndEvent;
end;
3. Implement the event-handler method:
procedure TForm1.myTemplateOnLoadEndEvent(Sender: TObject);
begin
{add code here to initial the report or data, etc. }
ppReport1.PrinterSetup.MarginTop := 0.5;
end;
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Yes that's that I use !
I have found an example in your tech tips news.
To access a component, I use a loop and I test on component name
But my question is: Is it possible to access TppVariable and modify the
value before printing ?
I have tried with Parameters list but It seem that I can't change value
of one variable ...
--
J-L M. (Alphomega)
Perso: http://alphomega.free.fr
Boulot: http://Ecilia.fr
Dodo: http://DansMonlit.fr
Sorry about that, I misunderstood the question. Parameters are probably the
best way to go with this. The reason the TppVariable's value is not showing
up is because ReportBuilder initialized all variable values before the
report prints. When using parameters, you will need to update the
TppVariable's value inside the OnCalc event to change it successfully.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
:-)
Thanks a lot !
--
J-L M. (Alphomega)
Perso: http://alphomega.free.fr
Boulot: http://Ecilia.fr
Dodo: http://DansMonlit.fr