Icart
asked on
TAdoQuery Not Updating All Records at runtime
I have a form with a TAdo Query. When you click the button it scrolls through the table and then updates the record.. Or so it should. e.g. when running the first record only is updated. If stepping through in debug/IDE then All records are correctly updated.
Using D7 connecting to Access Database. HELP PLEASE..
While not qryDataToCheck.Eof do
Begin
//Scroll Through the fields and do the checks on them
while not cdCheckData.Eof do
Begin
{OMITTED bOk False if error found}
qryDataToCheck.Edit;
if Not bOk then
begin
if bError then
qryDataToCheck.FieldByName ('Data_Err or_Found') .Value := 'E'
else qryDataToCheck.FieldByName ('Data_Err or_Found') .Value := 'W';
end
else
begin
qryDataToCheck.FieldByName ('Data_Err or_Found') .Value := Null ;
end;
qryDataToCheck.FieldByName ('Data_Err or_Comment ').Value := sRecordError;
qryDataToCheck.Post;
qryDataToCheck.Next;
end; //loop qryDataToCheck.eof
Using D7 connecting to Access Database. HELP PLEASE..
While not qryDataToCheck.Eof do
Begin
//Scroll Through the fields and do the checks on them
while not cdCheckData.Eof do
Begin
{OMITTED bOk False if error found}
qryDataToCheck.Edit;
if Not bOk then
begin
if bError then
qryDataToCheck.FieldByName
else qryDataToCheck.FieldByName
end
else
begin
qryDataToCheck.FieldByName
end;
qryDataToCheck.FieldByName
qryDataToCheck.Post;
qryDataToCheck.Next;
end; //loop qryDataToCheck.eof
It could be a timer-related issue. Maybe without the debugger running, the updates are too fast for Access to handle correctly. Then again, looking at your code extract, I noticed that the last end has a wrong comment. It is related to cdCheckData.Eof and not qryDataToCheck.Eof. So perhaps the problem is related to table-name confusion in your code.
first of all why you dont use UPDATE SQL like
Update TableName
set field1 = pla pla , .....
where <condition>
second
try to close the table at end of the procedure the makes the updates to your
table
Best Regards
Update TableName
set field1 = pla pla , .....
where <condition>
second
try to close the table at end of the procedure the makes the updates to your
table
Best Regards
ASKER
Apologise for the cdCheckData and The qryDataToCheck loopy bit. I am actually opening because I omitted code i didn't clip the correct do while.. The code runs perfectly as I say in IDE if I put a break in and then continue.. I have tried put sleep() command before the post and a process messages. The query rescordset state is open and not executing or fecthing and I am running out of ideas.
ASKER
I solved it.. Damn ADOQuery's. I changed the query to a Client Dataset and the code worked FINE!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.