[solved] Problem with Edit moving cursor to EOF
Posted: 25.03.2013, 02:34
Can someone please tell me why this only works one time after the aTbl.Edit. If I rem out the four lines for editing the table it iterates through all 49 records. It seems that the Edit and Post will position the file-cursor at the end of the file as I am only ever getting one record changed and it quits with the EOF.
I am using D5, Zeos-6 and SQLite3. I even tried grabbing the Auto-inc before the edit and then a Locate after it, but it still quits after the edit.
Thanks for anything you can suggest, but this has been driving me nuts all afternoon. I keep thinking it is something stupid I have done, but I cannot find it.
I have done some more research and if instead of .First, .Next and .EOF, I use .Last, .Prior and .BOF, it sits there forever in a loop as it never moves from the last position in the database.
I know I am using v6 and this is the v7 forum, but there seems to be little action on v6 forum and I need help to figure out how to resolve this issue. I can't use an SQL Query as there is nothing in the existing file that I can key ( WHERE ??? = ) the edits to.
I am using D5, Zeos-6 and SQLite3. I even tried grabbing the Auto-inc before the edit and then a Locate after it, but it still quits after the edit.
Thanks for anything you can suggest, but this has been driving me nuts all afternoon. I keep thinking it is something stupid I have done, but I cannot find it.
I have done some more research and if instead of .First, .Next and .EOF, I use .Last, .Prior and .BOF, it sits there forever in a loop as it never moves from the last position in the database.
I know I am using v6 and this is the v7 forum, but there seems to be little action on v6 forum and I need help to figure out how to resolve this issue. I can't use an SQL Query as there is nothing in the existing file that I can key ( WHERE ??? = ) the edits to.
Code: Select all
aTbl.First; // Test DB has 49 records
while not aTbl.EOF do
begin
for i := 0 to lbCt.Items.Count-1 do // Currently only two items in the list
begin // and only the second makes a match
aMatch := False; // which then forces the edit
CtStr := lbCt.Items[i]);
case InOut.ItemIndex of
0: aMatch := aTbl.FieldByName(fld_A).AsString = CtStr;
1: aMatch := aTbl.FieldByName(fld_B).AsString = CtStr;
2: aMatch := (aTbl.FieldByName(fld_A).AsString = CtStr) or
(aTbl.FieldByName(fld_B).AsString = CtStr);
3: aMatch := (aTbl.FieldByName(fld_A).AsString = CtStr) and
(aTbl.FieldByName(fld_B).AsString = CtStr);
end;
if aMatch then
begin
aTbl.Edit;
aTbl.FieldByName('Account').AsString := lbCt.Items[i];
aTbl.FieldByName('Folder').AsString := lbCt.Items[i];
aTbl.Post;
end;
end;
aTbl.Next;
end;