Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Template Problem.

edited January 2003 in General
I'm using a Report component in my program. I have created 2 reports
templates.
1- Template 1
2- Template 2

Both are saved in a folder in my computer. I load them fine without
problems. At design time I have the firts report I created loaded in the
component design viewer. When I try compiling the application I get an error

[Error] Giros.pas(4906): Undeclared identifier: 'LbAgt_Code'

On the ppHeaderBand2BeforePrint event I've assigned a value to a label

procedure TGirosForm.ppHeaderBand2BeforePrint(Sender: TObject);
begin
LbAgt_Code.Caption:=DM.AGTINFtbl.FieldByName('AGENT_CODE').AsString;
end;

If I comment that line the application compiles and run, but If I load the
second Report Template then I get the same error on the other event of the
first template.

Question.
How can I at design time have my reports templates read by Delphi.? So I
don't get this Error.
Do I need to use a report component for each report template at design
time.?? I did that and the problem goes away. But I need to create several
reports around 30 do I need to have 30 TppReports components on my form??

Please help.
PS. I load the templates at run time as explained in the developer manual.

rbReports.Template.FileName:='C:\Order Express\Reports\Giro_Invoice.rtm';
rbReports.Template.LoadFromFile;
rbReports.DeviceType:='Screen';
rbReports.Print;

Regards
Charles Urbina

Comments

  • edited January 2003
    You have event handlers that are referencing objects that are defined in the
    other template which are not loaded because you have the other template
    loaded. The objects are not in the form at compile time and so Delphi can't
    compile that. You'll want RAP (RB Enterprise only) in order to be able to
    store the calculations inside the report templates so you are not tied to
    event handlers in a form unit. This is the most flexible way to store
    reports which have event handlers.

    The alternative is to not use templates, but use one form per report
    component so the event handlers are not mixed together in one unit. And you
    can alos locate them all, with report components, on one form too.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.