Auto Load A RTM File At Runtime
Good Day,
I have a problem where i want to load a saved RTM File automatically on
runtime, so whenever someone changes the report on runtime and saved it
and will be loaded the next time the program is started.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
I have a problem where i want to load a saved RTM File automatically on
runtime, so whenever someone changes the report on runtime and saved it
and will be loaded the next time the program is started.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
This discussion has been closed.
Comments
I would suggest using the template event(s) OnSaveStart or OnSaveEnd to keep
track of the template file name after it has been saved to file by the user.
This file name would need to be kept somewhere on disk as you will loose all
information from the report once the application has closed. Below is a
small article on using template events.
----------------------------------------------
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;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks A Lot For It, However I Found Just A Simple Way To Do It:
procedure TForm1.Label33Click(Sender: TObject);
begin
GS14ReportCard.Template.FileName := 'C:\ESS\Bin\GS14ReportCard.rtm';
GS14ReportCard.Template.LoadFromFile;
GS14ReportCard.Print;
end;