IIf statement in update query

R

Radhika

I am trying to include multiple IIf criteria into a single field in an updae
query. Here is what I have:
UPDATE tbl_TEPRecords SET tbl_TEPRecords.[VP Other:Glue of valve/hinge] =
IIf([VP Other:Extra Increased Resistance]=-1,-1,0 And IIf([VP Other: Extra
Extra Increased Resistance]=-1,-1,0));
The update works for the first IIf statement, but not for the second. What
am I doing wrong?

Thank you
Radhika
 
K

KARL DEWEY

Your syntax is wrong. Do you want to update only when both are true?
Then this --
UPDATE tbl_TEPRecords SET tbl_TEPRecords.[VP Other:Glue of valve/hinge] =
IIf([VP Other:Extra Increased Resistance]=-1 And [VP Other: Extra Extra
Increased Resistance]=-1,-1,0);

Do you want to update when either one are true?
Then this --
UPDATE tbl_TEPRecords SET tbl_TEPRecords.[VP Other:Glue of valve/hinge] =
IIf([VP Other:Extra Increased Resistance]=-1 OR [VP Other: Extra Extra
Increased Resistance]=-1,-1,0);
 
R

Radhika

Thank you! I wanted to update when either were true.

I have another question:
How would I add the following criteria- [VP Other:Glue of valve/hinge]
should also = -1 if [VP Other: Increased Resistance] = -1 and [VP Type] =
[InHealth Low Pressure] or [InHealth Indwelling], -1,0 (if this criteria is
not met, its should be false)?

Thank you
Radhika

KARL DEWEY said:
Your syntax is wrong. Do you want to update only when both are true?
Then this --
UPDATE tbl_TEPRecords SET tbl_TEPRecords.[VP Other:Glue of valve/hinge] =
IIf([VP Other:Extra Increased Resistance]=-1 And [VP Other: Extra Extra
Increased Resistance]=-1,-1,0);

Do you want to update when either one are true?
Then this --
UPDATE tbl_TEPRecords SET tbl_TEPRecords.[VP Other:Glue of valve/hinge] =
IIf([VP Other:Extra Increased Resistance]=-1 OR [VP Other: Extra Extra
Increased Resistance]=-1,-1,0);


--
KARL DEWEY
Build a little - Test a little


Radhika said:
I am trying to include multiple IIf criteria into a single field in an updae
query. Here is what I have:
UPDATE tbl_TEPRecords SET tbl_TEPRecords.[VP Other:Glue of valve/hinge] =
IIf([VP Other:Extra Increased Resistance]=-1,-1,0 And IIf([VP Other: Extra
Extra Increased Resistance]=-1,-1,0));
The update works for the first IIf statement, but not for the second. What
am I doing wrong?

Thank you
Radhika
 
K

KARL DEWEY

Not sure if I got what you want. Try the select query then backup the
database before running the update query.
SELECT [VP Other: Increased Resistance], [VP Type], [InHealth Low Pressure]
[InHealth Indwelling], IIf(([VP Other: Increased Resistance]=-1( And
([VP Type] = [InHealth Low Pressure] OR [VP Type] = [InHealth Indwelling]),
-1, 0) AS Set_X
FROM tbl_TEPRecords;


UPDATE tbl_TEPRecords SET tbl_TEPRecords.[VP Other:Glue of valve/hinge] =
IIf(([VP Other: Increased Resistance]=-1( And ([VP Type] = [InHealth Low
Pressure] OR [VP Type] = [InHealth Indwelling]), -1, 0);

--
KARL DEWEY
Build a little - Test a little


Radhika said:
Thank you! I wanted to update when either were true.

I have another question:
How would I add the following criteria- [VP Other:Glue of valve/hinge]
should also = -1 if [VP Other: Increased Resistance] = -1 and [VP Type] =
[InHealth Low Pressure] or [InHealth Indwelling], -1,0 (if this criteria is
not met, its should be false)?

Thank you
Radhika

KARL DEWEY said:
Your syntax is wrong. Do you want to update only when both are true?
Then this --
UPDATE tbl_TEPRecords SET tbl_TEPRecords.[VP Other:Glue of valve/hinge] =
IIf([VP Other:Extra Increased Resistance]=-1 And [VP Other: Extra Extra
Increased Resistance]=-1,-1,0);

Do you want to update when either one are true?
Then this --
UPDATE tbl_TEPRecords SET tbl_TEPRecords.[VP Other:Glue of valve/hinge] =
IIf([VP Other:Extra Increased Resistance]=-1 OR [VP Other: Extra Extra
Increased Resistance]=-1,-1,0);


--
KARL DEWEY
Build a little - Test a little


Radhika said:
I am trying to include multiple IIf criteria into a single field in an updae
query. Here is what I have:
UPDATE tbl_TEPRecords SET tbl_TEPRecords.[VP Other:Glue of valve/hinge] =
IIf([VP Other:Extra Increased Resistance]=-1,-1,0 And IIf([VP Other: Extra
Extra Increased Resistance]=-1,-1,0));
The update works for the first IIf statement, but not for the second. What
am I doing wrong?

Thank you
Radhika
 

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

Similar Threads


Top