Re: syntax in long iif



Paretheses are your enemy. You need add a couple closing parentheses at the
end of the expression and remove them from the middle

IIF( [TableE].[Sites] >0 and [TableE].[Subjects]=0,
"Sites ("&[TableE].[Sites]&")",
IIF([TableE].[Sites] =0 and [TableE].[Subjects]>0,
"Subjects (&[TableE].[Subjects]&")",
IIF ([TableE].[Sites] >0 and [TableE].[Subjects]>0,
"Sites ("&[TableE].[Sites]& ") Subjects(" & [TableE].[Subjects] & ")" )))


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Jennyrd" <Jennyrd@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:14168910-84B0-49F0-9F81-09325DA48FE0@xxxxxxxxxxxxxxxx
I'm doing a long conditional statement that checks if 2 fields have 0 or
>0
values. It must be a problem with the syntax I'm using. Here's my code
that
is erroring out:

Currently: iif( [TableE].[Sites] >0 and [TableE].[Subjects]=0,"Sites
("&[TableE].[Sites]&")"), iif ([TableE].[Sites] =0 and
[TableE].[Subjects]>0,"Subjects (&[TableE].[Subjects]&")"), iif
([TableE].[Sites] >0 and [TableE].[Subjects]>0,"Sites ("&[TableE].[Sites]&
")
Subjects(" & [TableE].[Subjects] & ")")

Let me translate what I'm trying to do here for those who may be mystified
at my code :) :
if sites >0 and subjects=0 then Sites(1)
or
if sites=0 and subjects>0 then Subjects(15)
or
if sites and subjects >0 then Sites(8) Subjects(10)
Thanks a ton for any useful suggestions!!!
-Jenny


.



Relevant Pages

  • Re: Time a query
    ... Access MVP 2002-2005, 2007-2008 ... John Spencer wrote: ... You add a table to your database name named QueryResults with 4 fields: ... Dim dbAny As DAO.Database ...
    (microsoft.public.access.queries)
  • Re: Time a query
    ... "John Spencer" wrote: ... Access MVP 2002-2005, 2007-2008 ... You add a table to your database name named QueryResults with 4 fields: ... Dim dbAny As DAO.Database ...
    (microsoft.public.access.queries)
  • Re: check mark to filter data or not
    ... Dave Hargis, Microsoft Access MVP ... "John Spencer" wrote: ... ALL records when the checkbox on the form was false and only the true ... If check0 is false then return records where yesno fields are false or ...
    (microsoft.public.access.queries)
  • Re: Why Re-Link causes Corruption
    ... Doug Steele, Microsoft Access MVP ... "John Spencer" wrote: ... Try Allen Browne's article on Recovering from Corruption at: ... Oracle is not it, I've tried it on a db with no links to Oracle ...
    (microsoft.public.access.modulesdaovba)
  • Re: Multiple Cascading Combo Box
    ... Dave Hargis, Microsoft Access MVP ... "John Spencer" wrote: ...
    (microsoft.public.access.modulesdaovba)