A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

IIF statements with or signs



 
 
Thread Tools Display Modes
  #1  
Old July 6th, 2009, 08:21 PM posted to microsoft.public.access
Burton
external usenet poster
 
Posts: 19
Default 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  
Old July 6th, 2009, 08:26 PM posted to microsoft.public.access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default 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  
Old July 6th, 2009, 08:30 PM posted to microsoft.public.access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default 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  
Old July 7th, 2009, 12:54 AM posted to microsoft.public.access
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.