Board index » delphi » Problem with a little program... HELP!!!

Problem with a little program... HELP!!!

I have a little source code that is making me a
lot of problems:

procedure TForm1.Table1CalcFields(DataSet: TDataset);
var i: integer;
    s: string;
begin
     i := 1;
     Table1.First;
     repeat
          Table1.Edit;
          Table1.FieldByName('ST_ZAPISA').AsInteger := i;
          Table1.Post;
          Table1.Next;
          Inc(i);
     until Table1.EOF;
end;

This should work fine, but it comes to Table1.Post it just
jumps back to begin!! Does anyone know what the problem
could be?

Please E-Mail

 

Re:Problem with a little program... HELP!!!


OnCalcFields is not intended for traversing a Dataset like you are doing.
Which brings up the question... what are you doing?  When you place the
table in edit state and change one of its fields, the post method will fire
OnCalcFields, just as it has here.  I would be surprised if you ever got
out of this loop.

In fact, you are not really supposed to modify any non-calculated fields
within the OnCalcFields event handler.  It is interested that Delphi
allowed you to do this.

Otherwise, your code looks fine.  When do you really want it to run?

[also e-mailed]

Ken
--------------------------------------
Notice at no time do my fingers leave my hands...
This Internet thing...  it's a fad!  ;-)
--------------------------------------
Master Certified Delphi 3 Instructor
Master Certified C++Builder Instructor
k...@knowledgeable.com
ka...@oakland.edu
+

ZoneMan <Rok.An...@guest.arnes.si> wrote in article
<5jv6be$ol...@kanja.arnes.si>...

Quote
> I have a little source code that is making me a
> lot of problems:

> procedure TForm1.Table1CalcFields(DataSet: TDataset);
> var i: integer;
>     s: string;
> begin
>      i := 1;
>      Table1.First;
>      repeat
>           Table1.Edit;
>           Table1.FieldByName('ST_ZAPISA').AsInteger := i;
>           Table1.Post;
>           Table1.Next;
>           Inc(i);
>      until Table1.EOF;
> end;

> This should work fine, but it comes to Table1.Post it just
> jumps back to begin!! Does anyone know what the problem
> could be?

> Please E-Mail

Other Threads