I would like to force a report to stop processing and display the results instead of having it iterate through an entire dataset. The band iterates through dataset one, then in frDBDataset1CheckEOF I check for a condition from another dataset. If the condition arises, I return EOF as True.
The report continues to process and two additional calls to CheckEOF before I get a record not accessible error and crashes the report.
Perhaps I may not be using CheckEOF properly.
Both datasets are TDBF's.
BeginBand maintains the relationships between the two datasets;
procedure TSelection.frReport1BeginBand(Band: TfrBand);
var
filtStr : String;
found : Boolean;
begin
if Band.Name = 'Body' then Begin
case Print_By.Text of
'Name': Begin
// O_L_List.Next; // Report iterates O_L_List with Band
if O_L_List.FieldByName('Name_RecNo').AsInteger <> Names.FieldByName('RecNum').AsInteger then
Begin
Names.Next; found := not (Names.BOF or Names.EOF);
if found then begin
O_L_List.Filtered := false;
filtStr := 'Name_RecNo >= ' + Names.FieldByName('RecNum').AsString;
O_L_List.Filter := filtStr;
O_L_List.Filtered := True;
O_L_List.First;
end;
end;
end;
. . . //more case statement conditions
end;
end;
end;
Then I check the second dataset to see if its reached the condition to stop the report.
procedure TSelection.frO_L_ListCheckEOF(Sender: TObject; var Eof: Boolean);
var
lname, zip, endWith : String;
begin
lname := Names.FieldByName('LName_CO').AsString;
zip := Addr.FieldByName('Zip').AsString;
endWith := End_With.Text;
case Print_By.Text of
'Name' :
if (CompareText(lname, endWith) > 0) then
EOF := True;
. . . // more case conditions
end;
end;
Or if there's another way to do this I would be happy to entertain that as well. Thank you for your suggestions.
Vitals:
Lazarus Version: 1.2.2
Date: 2014-04-24
FPC Version: 2.6.4
SVN Revision: 44758
i386-win32-win32/win64