RecordIndex out of range - DevExpress

1.3k Views Asked by At

I am having issues with a DevExpress VCL grid, throwing out a "RecordIndex out of range" error, despite not directly calling any record functions of the grid in that scenario.

What I am doing is fairly simple: once the record is changed(AfterScroll), a method is called. Inside this method, I call another method which assigns the data source and data fied name according to a field in the new record.

The code is pretty simple and goes like this:

procedure TValidatedOrders.UpdateDispenseNotes;
var Dataset : TDataSet;
    GroupTypeFieldName : String;
    DataSource : TDataSource;
    DataFieldName : String;
    GroupType : Integer;

    procedure SetSpecsDataSource;
    begin
         DataSource := DMValidatedDispense.DSDispenseGroupSpecs;
         DataFieldName := 'GLAZING_INSTRUCTIONS';
    end;

    procedure SetCLsDataSource;
    begin
         DataSource := DMValidatedDispense.DSDispenseGroupCLs;
         DataFieldName := 'WEAR_INSTRUCTIONS';
    end;
begin
     // Step 1: Get the group type
     If GetTopPage = cTopPageOrders Then
        Dataset := DMValidatedDispense.CDSLabOrders
     Else
        Dataset := DMValidatedDispense.CDSLabDispenses;

     GroupType := Dataset.FieldByName( 'GROUP_TYPE' ).AsInteger;
     // Step 2: Assign the MemoDispenseNotes data binding appropriately
     If GetTopPage = cTopPageOrders Then
     Begin
         case GroupType of
         cOrderGroupSpecs, cOrderGroupFrame,
         cOrderGroupLens, cOrderGroupGlazing: SetSpecsDataSource;
         cOrderGroupCLs: SetCLsDataSource;
         else SetSpecsDataSource;
         end;
     End
     Else
     Begin
          case GroupType of
          cDispenseGroupSpecs: SetSpecsDataSource;
          cDispenseGroupCLs: SetCLsDataSource;
          else SetSpecsDataSource;
          end;
     End;
     MemoDispenseNotes.DataBinding.DataSource := DataSource;
     MemoDispenseNotes.DataBinding.DataField := DataFieldName;     
end;

The original code where the above method is called is just too long to report here, anyway it contains stuff like panels show/hide, checks of the type .FieldByName( 'GROUP_TYPE' ).AsInteger = SomeValue and so on: there's no locate, no FindKey or anything like that.

As I said, there's no record selection directly involved(not sure here what's going on inside the DevExpress grid though...) and I don't see why I'd be getting such error.

Anybody has got a brilliant idea of what could be going on?

Thank you very much!

1

There are 1 best solutions below

0
On BEST ANSWER

AFAICS this method only changes the DataSource of a TcxDBMemo component. The culprit must be elsewhere and is most probably some event.

As a first step to debug it, I would try to use BeginUpdate and EndUpdate on the view of your grid at the beginning and end of the code.