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

TppReport.Reset not working

edited December 2001 in General
Im trying to print a report several times while changing the underlying
data. I get the data for the first report fine but the only way to get
'fresh' data on subsequent reports is to reload the rtm file. I have
tried everything I can think of including:
TppReport.Reset
TppReport.Engine.Reset;
TppReport.ResetDevices;
TppReport.Publisher.Reset;
TppReport.DataPipeline.FreeBookmarks;

code:

procedure TForm1.Button4Click(Sender: TObject);
begin
ppReport2.Template.FileName := 'c:\AReport.rtm';
ppReport2.Template.LoadFromFile;
ppReport2.DeviceType := 'Screen';

que.Active := TRUE; // query with list of accts to print report for
que.First;
while not que.EOF do
begin
queScratch.Parameters.ParamByName('AKeyValue').Value :=
que.FieldByName('AKeyValue').AsInteger;
queScratch.ExecSQL; // update the data the report uses
// ppReport2.Template.LoadFromFile; // This works fine
ppReport2.Reset; // <<< DOESNT WORK!
ppReport2.Print;
que.Next;
end;
end;

Report Builder Enterprise Edition ver 6.03
D5 build 6.18 Update Pack 1
ADOExpress patch 2
NT 4.0 SP 6

Comments

  • edited December 2001
    You are doing something very similar to our Autosearch approach. See the
    installed RBuilder\Demos\Autosearch directory for an example of setting
    query params in the first example folder. You'll notice that we close the
    query so that the datapipeline for the report will reopen the query and
    retrieve the data. You are going to want to close queScratch query after
    you change its params. Then rely on the fact that the report datapipeline
    will have to open the query in order to run the report.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited December 2001
    queScratch doesnt contain a result set it is used to run an update
    statement on the DB. Notice it calls ExecSQL not Open. The report
    contained in the rtm file has the query I need re-run so the report will
    see the data modified by my update statement.

  • edited December 2001
    The load from file works because the datapipelines are getting reinitialized
    (the queries are reopened).

    The ExecSQL should work when you call Active first. Normally, ExecSQL is
    not used for Select statments, however, ADO has this Active property
    "feature." If you close the report's query after running the report, then
    it should work. I created a test project with two ADO queries and manually
    assigned the parameter for a query that the report was based on and it
    worked when I closed the report's query after I was done with it. If I
    didn't close the query, then I get the behavior you have described.

    qryMaster.Open;
    qryDetail.Active := True;

    while not(qryMaster.EOF) do
    begin

    qryDetail.Parameters.ParamByName('sqCustomer').Value :=
    qryMaster.FieldByName('sqCustomer').AsInteger;

    qryDetail.ExecSQL;

    ppReport1.Print;

    qryMaster.Next;

    qryDetail.Close;

    end;

    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.