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

AV Error using Templates

edited October 2002 in General
I have a program that uses report templates, in the template I have a
group band, with a rap function I check to see if I need the group
band and free if I don't. In RB 603 this worked fine, but now with RB
7 I get an Access Violation when I try to free the group band, below
is a sample of the code in the template that does this:

Procedure ReportBeforePrint;
Var
DoGroupBy: Boolean;
begin
Group1.KeepTogether := False;
Report.PassSetting := psOnePass;
{Report.Units := utScreenPixels;}
Report.DataPipeLine := DPLINVEN;

{Setup our report title}
ReportName.Caption := asReportTitleField;

{Make our title box wider than the report title}
{TitleBox.Pen.Width := 2;
HeaderBarLine.Pen.Width := 1;}

DoGroupBy := (asGroupByField <> '');

GroupHeaderBand1.Visible := DoGroupBy;
GroupFooterBand1.Visible := DoGroupBy;

If DoGroupBy Then
Begin
Group1.BreakName := asGroupByField;
DBGroupBy.DataField := asGroupByField;
GroupRecs.Value := 0;
End
Else
Group1.Free;

{TotalRecords.CalcType := veTraversal;}
TotalRecords.DataType := dtInteger;

ReportScope.Caption := GetScope;
end;

Can anyone tell me why this is happening?

David Looney

Comments

  • edited October 2002
    Freeing/creating layout components is not a good idea when using RAP. RAP is
    intended to be used while the report engine is running for end users.
    Perhaps, this limits what you as a developer can do with RAP, like not being
    able to create the whole layout using RAP. However, RAP is part of the
    layout as it is in the template and it was intentionally limited to work for
    end users as the scripting language to control the report during generation.

    What is happening is that the RAP BeforePrint event fires too late in the
    generation process (after first page request) as opposed to the BeforePrint
    event that you would assign to use in Delphi (when the report intializes).

    What you can do is turn off the group bands by setting them to visible
    false. Then make sure the group object has its KeepTogether and NewPage
    properties set to false so that it doesn't affect the pagination.


    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.