Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql edit Problem

Status
Not open for further replies.

Pietjeparasietje

Programmer
Jun 13, 2005
55
NL
Hi Guys,

I've got another silly problem, which you guys can probably fix in just a sec, but I can't find the solution.

All I'm trying to do is select a record, and change a field of that selected record:

Code:
qrySetFlag.SQL.Text := 'Select * from Item where ItemNumber = '+QuotedStr(Item);
        qrySetFlag.Active := true;
        qrySetFlag.edit;
        qrySetFlag.FieldByName('Flag').text := 'Yes';
        qrySetFlag.next;
        qrySetflag.Close;

The sql statement is fine, and it does enter the data into that field, but as soon as I want to change it I get an :

"
[Microsoft][ODBC Microsoft Access Driver] Query is too complex.
"
error.
Just can't find what's wrong with it, this always works.
Please help, thanks,

Peter
 
try this:

Code:
with qrySetFlag do
begin
  SQL.Add('Select * from Item where ItemNumber = '+ QuotedStr(Item));
  Active := true;
  edit;
  FieldByName('Flag') := 'Yes';
  Post;
  Active := False;
end;

Is 'Flag' a boolean/logical field in your Access table? Then it would need to be a zero.


Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual
 
Thanks for youre reply, but the code youre suggesting does not change anything. Btw, Flag is just a String field.

I think the problem might have to do something with the amount of fields. I'm having 200 something fields in this table, and I think that this might have to something with it.

Thanks,

Peter
 
do you need all 200 fields? WHy are you running it this way instead of an update query anyway?
Code:
with qrySetFlag do
begin
  SQL.Clear;
  SQL.Add('UPDATE Item SET Flag = 'Yes' WHERE ItemNumber = '+ QuotedStr(Item));
  ExecSQL;
end;

must have still be asleep when I responded before or I would have snapped.

les
 
Right!, that's what I said, the answer will be rather easy but just couldn't get to it.

But the updating does the trick, THANKS!

Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top