Using an IIF statement in an Access Query, how can I check if a c.

S

SemperFi 1967

I have a text field that contains various messages for each record. Based on
a possible specific text sequence in that field, I want to perform a
calculation on another field. How can i use either a function that will look
to see if that part of the string is in there? My Query statement looks like
this: Adjustment Cost: IIF ([text field] contains "TKT Charge",
+10.00,). What is the function that would supplant "contains"? Any help
would be greatly appreciated.

Ken
 
M

Marshall Barton

I have a text field that contains various messages for each record. Based on
a possible specific text sequence in that field, I want to perform a
calculation on another field. How can i use either a function that will look
to see if that part of the string is in there? My Query statement looks like
this: Adjustment Cost: IIF ([text field] contains "TKT Charge",
+10.00,). What is the function that would supplant "contains"?

Here's how you would write that:
IIF ([text field] LIKE "*TKT Charge*", 10.00, 0)

FYI, it is a poor idea to embed this kind of thing in a
field with other stuff. It's much better to normalize the
data by having separate field for things like this optional
charge. Perhaps a Yes/No field would serve this need?
 
D

Duane Hookom

IIf() should have 3 arguments. I believe you need
IIf(Instr([Text Field],"TKT Charge")>0,10,0)
 

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

Top