Create temporary table, insert the PK's iterating on the Grid's SelectedRows property,
and let the report based on the JOIN between the temporary and the displayed dataset.
I think the better way to solve this problem is:
- To create an array or a list with all numbers of rows is selected in your dbgrid
- To create a frUserDataset to control the navigation in your array
- In report event onGetValue you can access the row in dbgrid using the array like an index
I had use this way to solve similar problem, but with stringgrid an works fine and faster.
I have a (Client)Dataset showed in de DBGrid.
I show some fields for selection (and there is a field FieldID wich is not shown).
There is also a (ADO) temp table and a sql-string for using in this table (the sql is without the where part)
procedure TForm1.ButtonPrintClick(Sender: TObject);
var i: Integer;
  S: string;
  BML: TBookmarkList;
begin
BML:= DBGrid1.SelectedRows;
if BML.Count = 0 then //no records
 Abort;
S:= '';
with DBGrid1.DataSource.DataSet do begin
 DisableControls;
 try
 for i:= 0 to BML.Count-1 do begin
  Bookmark:= BML[i];
  S:= S + ', '+FieldByName('FieldID').AsString;
 end;//for
 finally
 EnableControls;
 end;//try-finally
end;//with
Delete(S, 1,1);//delete 1th comma
with DM.AdsTmp do begin
 Close;
 CommandText:= sSQL +
 'AND TheID IN ('+S+') ';
 //ORDER BY ...
 Open;
 //Print AdsTmp
end;
end;
The FastReport part is not so difficult when you have a good SQL, with a field for each showed memo.
Comments
and let the report based on the JOIN between the temporary and the displayed dataset.
Regards:Alex
I think the better way to solve this problem is:
- To create an array or a list with all numbers of rows is selected in your dbgrid
- To create a frUserDataset to control the navigation in your array
- In report event onGetValue you can access the row in dbgrid using the array like an index
I had use this way to solve similar problem, but with stringgrid an works fine and faster.
Regards
Luciano
I have a (Client)Dataset showed in de DBGrid.
I show some fields for selection (and there is a field FieldID wich is not shown).
There is also a (ADO) temp table and a sql-string for using in this table (the sql is without the where part)
The FastReport part is not so difficult when you have a good SQL, with a field for each showed memo.
I have to print selected rows and just skip/jump/no print other