Using AfterFetch didn't seem to work and gives an error.
I have a FastReport (FrxReport1) joined in the normal, correct way via a fastreport dataset and a datasource to the MyDAC query.
Showing the report opens the datasource in the normal way and displays whatever is in the query. The SQL is generated elsewhere and returns 11 rows. MyQueryMembersInRadius.FetchAll is set to true.
This code works correctly. 
There is a delay while the sql executes and then the report opens showing the data.
Code: Select all
procedure ShowTheReport;
begin
  MyQueryMembersInRadius.Close; //close the MyDac query
  MyQueryMembersInRadius.SQL.Clear ;
  MyQueryMembersInRadius.SQL.Add(sql) ;
  screen.cursor := crhourglass;
  MyQueryMembersInRadius.open;
  screen.cursor := crdefault;
  frxReport1.showreport(true);
end;
However, splitting it to use AfterFetch so that I only open the report after all the data is available, like this
Code: Select all
Procedure ShowTheReport;
begin
  MyQueryMembersInRadius.Close; //close the MyDac query
  MyQueryMembersInRadius.SQL.Clear ;
  MyQueryMembersInRadius.SQL.Add(sql) ;
  screen.cursor := crhourglass;
  MyQueryMembersInRadius.open;
end;
procedure TFrm1.MyQueryMembersInRadiusAfterFetch(DataSet: TCustomDADataSet);
begin
  screen.cursor := crdefault;
  frxReport1.showreport(true);
end;
always gives me an error 'SQL command doesn't return rows' as soon as it tries to open the report
Any ideas?
(It's not a huge deal as I can get it to work without using AfterFetch but I'd be interested in the reason for failure)