Board index » delphi » To move or not to move

To move or not to move

Hi

Using Delphi 6, Jet and the code below.
All of below works fine, the program loops through the recordset and bails
out when end of file is true, however the command
dbform.tb.FieldByName('code').AsString always returns the value of the first
record.
I am probably missing something very simple but can someone tell me what it
is.

  if depotcount<>0 then
  begin
    dbform.tb.recordset.movefirst;
    f:=0;
    while not dbform.tb.Recordset.EOF do
    begin
      LocDepot[f] := dbform.tb.FieldByName('code').AsString;
      inc(f);
      dbform.tb.recordset.MoveNext;
    end;
  end;

Thanks
Nevik

 

Re:To move or not to move


Its OK got it

I replaced - dbform.tb.recordset.MoveNext;

with - dbform.tb.Next;

and it worked,
cool

Nevik

Quote
"Kev Martin" <k...@mbssoft.co.uk> wrote in message

news:afbt1m$d73ma$1@ID-145325.news.dfncis.de...
Quote
> Hi

> Using Delphi 6, Jet and the code below.
> All of below works fine, the program loops through the recordset and bails
> out when end of file is true, however the command
> dbform.tb.FieldByName('code').AsString always returns the value of the
first
> record.
> I am probably missing something very simple but can someone tell me what
it
> is.

>   if depotcount<>0 then
>   begin
>     dbform.tb.recordset.movefirst;
>     f:=0;
>     while not dbform.tb.Recordset.EOF do
>     begin
>       LocDepot[f] := dbform.tb.FieldByName('code').AsString;
>       inc(f);
>       dbform.tb.recordset.MoveNext;
>     end;
>   end;

> Thanks
> Nevik

Other Threads