Recent

Author Topic: frDBDataSet.OnCheckEOF does not seem to work correctly  (Read 3039 times)

tshumak

  • New Member
  • *
  • Posts: 36
frDBDataSet.OnCheckEOF does not seem to work correctly
« on: June 01, 2014, 10:40:30 am »
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;
Code: [Select]
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.
Code: [Select]
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

tshumak

  • New Member
  • *
  • Posts: 36
Re: frDBDataSet.OnCheckEOF does not seem to work correctly
« Reply #1 on: June 11, 2014, 10:01:58 am »
Perhaps is there a way to stop the report similar to clicking the cancel button on the progress dialog?  Anybody?

 

TinyPortal © 2005-2018