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

Table Won't Open second time..

edited April 2017 in General
Hi Team,
Win 10, D10.1, RB18.01.

I have a table that gets filtered. I then copy the filtered contents to a temp table, I then run a report on the
contents of the temp table. See code below..

{code}
//
ApptTemp.Close;
ApptTemp.Open; << Fails here the second time round.
ApptTemp.AdsZapTable;
//
Appointments.AdsCopyTableContents(ApptTemp);
//
ApptTemp.Close;
//
with ReportsFrm.ReportsForm do
begin
ppRE1.LoadReport('Appointments', 2);
ppR1.Icon.LoadFromFile('DBWorkflow.ico');
ppR1.ShowAutoSearchDialog := False;
ppR1.Print;
end;
//
{code}

The concept here is that the end user can set any filter they like on the primary table (Appointments) and then report
on it via the secondary (ApptTemp).

On first run it works perfectly.

My issue is that on the second running, even without changing the filter condition, the app fails at ApptTemp.Open.

If I comment out the With...End, for the report generation I get no error.

Seemingly the Report Engine is keeping hold of ApptTemp after the report generation. If this is the case, is there
something I can do to force a release?

Regards & TIA,
Ian

Comments

  • edited April 2017
    Hi Ian,

    We have not seen this behavior before.

    My first suggestion is to try setting PreviewFormSettings.SinglePageOnly
    to True and see if you still get the error.

    Another option would be to try closing or disconnecting the report's
    pipeline before altering the temporary table.

    RP1.DataPipeline.Close;

    ApptTemp.Close;
    ApptTemp.Open; << Fails here the second time round.
    ApptTemp.AdsZapTable;
    //
    Appointments.AdsCopyTableContents(ApptTemp);

    ...

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2017
    Hi Nico,
    Thank you for your response. Forgot to mention but you probably guessed, I am using Advantage Database. v 12.

    I tried both suggestions.

    Changing the setting PreviewFormSettings.SinglePageOnly to True did nothing, same result.

    Closing the pipeline at the position shown:
    {code}
    ReportsFrm.ReportsForm.ppR1.DataPipeline.Close;
    //
    ApptTemp.Close;
    ApptTemp.Open;
    ApptTemp.AdsZapTable;
    {code}
    resulted in a different error.

    Moving the datapipeline close into the With.. structure:
    {code}
    with ReportsFrm.ReportsForm do
    begin
    ppRE1.LoadReport('Appointments', 2);
    ppR1.Icon.LoadFromFile('DBWorkflow.ico');
    ppR1.ShowAutoSearchDialog := False;
    ppR1.Print;
    ppR1.DataPipeline.Close;
    end;
    {code}
    ended with the original error..

    Moving the datapipele.close after the with:
    {code}
    with ReportsFrm.ReportsForm do
    begin
    ppRE1.LoadReport('Appointments', 2);
    ppR1.Icon.LoadFromFile('DBWorkflow.ico');
    ppR1.ShowAutoSearchDialog := False;
    ppR1.Print;
    end;
    //
    ReportsFrm.ReportsForm.ppR1.DataPipeline.Close;
    {code}
    gave the same original error result.

    Don't know where to go from here..:-(

    Regards,
    Ian
  • edited April 2017
    Tried this..
    {code}
    ApptTemp.Close;
    //
    with ReportsFrm.ReportsForm do
    begin
    ppRE1.LoadReport('Appointments', 2);
    ppR1.Icon.LoadFromFile('DBWorkflow.ico');
    ppR1.ShowAutoSearchDialog := False;
    ppR1.Print;
    ppR1.DataPipeline.Close;
    end;
    //
    ApptTemp.Open; << Error trying to open.
    //
    {code}

    Same error.

    Regards,
    Ian
  • edited April 2017
    Not a solution - A work around..

    {code}
    with ReportsFrm.ReportsForm do
    begin
    ppRE1.LoadReport('Appointments', 2);
    ppR1.Icon.LoadFromFile('DBWorkflow.ico');
    ppR1.ShowAutoSearchDialog := False;
    ppR1.Print;
    ppRE1.LoadReport('Job Ticket', 2);
    end;
    {code}

    It works.

    Regards,
    Ian
  • edited April 2017
    Hi Ian,

    Interesting, thanks for sharing your test cases.

    I'm going to need to see this in action to track down the cause. Please
    create a simple example that I can run here demonstrating the issue and
    I'll take a look at what is going on.

    Using Advantage is okay if you include the data.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2017
    Hi Nico,
    Ahh now that will be a challenge. The two forms are part of a 20+ form application.
    I will see what I can do.

    Regards,
    Ian
  • edited April 2017
    HI Nico,
    It was easier than I thought. :-)
    RBTest.rar sent to support@..
    See comment in Appointments source.

    Regards,
    Ian
This discussion has been closed.