Using IIF in UPDATE

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to execute an UPDATE on a single table that would look something
like:

UPDATE table SET IIF([F1] <> Me!cbxNumber, Me!cbxNumber),
IIF([F2] <> Me!cbxVendor, Me!cbxVendor);"

This syntax fails. Can someone please help me sort this out?

Thanks.
 
Sorry that SQL should read:

UPDATE table SET IIF([F1] <> " & Me!cbxNumber & ", " & Me!cbxNumber & "),
IIF([F2] <> " & Me!cbxVendor & ", " & Me!cbxVendor & ") WHERE ID = " &
Me!cbxID & ";"
 
I am trying to execute an UPDATE on a single table that would look something
like:

UPDATE table SET IIF([F1] <> Me!cbxNumber, Me!cbxNumber),
IIF([F2] <> Me!cbxVendor, Me!cbxVendor);"

This syntax fails. Can someone please help me sort this out?

Thanks.

It's not at all clear what you're trying to do. The SET clause should
be a fieldname - and you cannot use an IIF to return the fieldname.

Please explain WHAT it is that you are starting with, in your table
structure and form controls; and what you're trying to accomplish. I'm
sure it can be done, just not this way!

John W. Vinson[MVP]
 
The basic syntax for JET SQL UPDATE statement is:

UPDATE table
SET TableField = newvalue,
AnotherTableField = anothernewvalue
WHERE criteria;

Note the equal sign after each Table Field.

For example (from JET SQL Reference in Access Help):

UPDATE Orders
SET OrderAmount = OrderAmount * 1.1,
Freight = Freight * 1.03
WHERE ShipCountry = 'UK';

In your SQL, I can't see any equal sign for assignment.
 
and I cannot see any fields for the expressions to be SET equal to.

If you design the Update query in the QBE grid just put the fields in the
field row and the IIF statements into the "Update to: " row.

The QBE has been writing SQL longer than most of us :->

Van T. Dinh said:
The basic syntax for JET SQL UPDATE statement is:

UPDATE table
SET TableField = newvalue,
AnotherTableField = anothernewvalue
WHERE criteria;

Note the equal sign after each Table Field.

For example (from JET SQL Reference in Access Help):

UPDATE Orders
SET OrderAmount = OrderAmount * 1.1,
Freight = Freight * 1.03
WHERE ShipCountry = 'UK';

In your SQL, I can't see any equal sign for assignment.

--
HTH
Van T. Dinh
MVP (Access)



XP said:
I am trying to execute an UPDATE on a single table that would look
something
like:

UPDATE table SET IIF([F1] <> Me!cbxNumber, Me!cbxNumber),
IIF([F2] <> Me!cbxVendor, Me!cbxVendor);"

This syntax fails. Can someone please help me sort this out?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top