I have a strange problem. I have a dbgrid and am moving records up and down 
with buttons. (Delphi4)

The routine works 

If I uncomment the bookmark, it displays wrong figures in the seq and seq2 
columns on the record I was moving.

If I move a line and close the application, reopen it,  the figures are 
correct. It seem that only the display is incorrect when moving.


SEQ   SEQ2   Desc
20      20        Tool Select
25      25        Coolant on
30      30        Feed Rate

If I move "Coolant on" down I get 

20      20        Tool Select
30      30        Coolant on
25      25        Feed Rate
30      30       Coolant on

Close the application and reopen

20      20        Tool Select
25      25        Feed Rate
30      30        Coolant on

If I comment out the Bookmark, it works correctly but leaves me at the bottom 
of the list. 

procedure OperSort(sBM: String);
var
   iSeq : Integer;
begin
   with dm.tblOper do begin
      IndexName := 'OPERSEQ2';           // Swop to this new sort order
      Open;
      First;                               // go to the top
      iSeq:=5;                           // first record is 5
      while not Eof do begin
         edit;
         dm.tblOper['SEQ']:= iSeq;       // increase each recod by 5
         iSeq:=iSeq+5;
         dm.tblOper.post;
         dm.tblOper.next;
      end;
      close;
      IndexName := 'OPERSEQ';            // set back to the original order
      Open;
      First;
      while not Eof do begin
         edit;
         dm.tblOper['SEQ2']:= dm.tblOper['SEQ'];  // Update secondary index. 
         Post;
         Next;
      end;
      //  BookMark:=sBM;
   end;
end;

procedure TfMain.bMainDownClick(Sender: TObject);
var
  iSeq: Integer;
  sBookMark :String;
begin
   iSeq:=dm.tblOper.FieldByName('SEQ').AsInteger;  //get the current sequence 
number
   with dm.tblOper do begin
      iSeq:=iSeq+6;                             // Increase by 6
      edit;                                            // tbl seq numbers are 
multiple of 5's
      dm.tblOper['SEQ2']:= iSeq;
      Post;
      sBookMark:= BookMark;             // Position Cursor at current record.
      Close;
      OperSort(sBookMark);
   end;
end;
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with Subject: 
unsubscribe

Reply via email to