If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
IIF statements with or signs
am trying to write a query in Access, but I am having problems. If I write
it like this: IIf([Forms]![Form1]![Option22]=True,[Forms]![Form1]![Text6], "") than it works just fine. However, as soon as I add a or sign in the code, it stops working. This is what I want it to say: IIf([Forms]![Form1]![Option22]=True,=[Forms]![Form1]![Text6], ""). Do you know why the causes the query not to work? Do you know how I can fix it? |
#2
|
|||
|
|||
IIF statements with or signs
You cannot change operators using IIf statements.
You need to tell the query always use = [Forms]![Form1]![Text6], but only when [Forms]![Form1]![Option22] is true. That means your SQL will look something like: WHERE (MyTable.MyField = [Forms]![Form1]![Text6] AND [Forms]![Form1]![Option22] = True) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Burton" wrote in message ... am trying to write a query in Access, but I am having problems. If I write it like this: IIf([Forms]![Form1]![Option22]=True,[Forms]![Form1]![Text6], "") than it works just fine. However, as soon as I add a or sign in the code, it stops working. This is what I want it to say: IIf([Forms]![Form1]![Option22]=True,=[Forms]![Form1]![Text6], ""). Do you know why the causes the query not to work? Do you know how I can fix it? |
#3
|
|||
|
|||
IIF statements with or signs
"Burton" wrote in message
... am trying to write a query in Access, but I am having problems. If I write it like this: IIf([Forms]![Form1]![Option22]=True,[Forms]![Form1]![Text6], "") than it works just fine. However, as soon as I add a or sign in the code, it stops working. This is what I want it to say: IIf([Forms]![Form1]![Option22]=True,=[Forms]![Form1]![Text6], ""). Do you know why the causes the query not to work? Do you know how I can fix it? It doesn't work because each argument of the IIf() function must be a value, and "=[Forms]![Form1]![Text6]" can't be interpreted as a value. How exactly are you trying to use this expression? Are you putting it in a criterion cell of the query? That's the only way I can make sense of it. If that's the case, you *may* get what you're looking for with this: =IIf([Forms]![Form1]![Option22]=True,[Forms]![Form1]![Text6], "") But I don't know for sure. You'd have to explain in words what criteria you're trying to apply to the query. -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#4
|
|||
|
|||
IIF statements with or signs
Do you mean you want the literal characters "=" to preceed the contents of
Form1!Text6? Otherwise, recheck Access HELP for the syntax and examples of IIF(). Regards Jeff Boyce Microsoft Office/Access MVP "Burton" wrote in message ... am trying to write a query in Access, but I am having problems. If I write it like this: IIf([Forms]![Form1]![Option22]=True,[Forms]![Form1]![Text6], "") than it works just fine. However, as soon as I add a or sign in the code, it stops working. This is what I want it to say: IIf([Forms]![Form1]![Option22]=True,=[Forms]![Form1]![Text6], ""). Do you know why the causes the query not to work? Do you know how I can fix it? |
Thread Tools | |
Display Modes | |
|
|