Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / August 2007

Tip: Looking for answers? Try searching our database.

IIF statement problem in Query Criteria

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sally - 30 Aug 2007 22:38 GMT
I have a field "SumOfQty" in a query that I want to use an IIF statment in
the criteria: If [Forms]![Zero Qty]![Checkbox] is checked then "SumOfQty"
criteria is 0.
else >0.  The 0 works, but it won't see the >0.  What would be the solution
to get the same results another way?
kasab - 31 Aug 2007 03:28 GMT
Sally -

Try something like IIF([Forms]![Zero Qty]![Checkbox] = -1, 0, [fieldname])

where fieldname is the name of the field whose data you want to insert. If
no fieldname is applicable, try entering some number instead of fieldname,
like
IIF([Forms]![Zero Qty]![Checkbox] = -1, 0, 3) (for example).

If this isn't what you need, would you post your IIF expression.

> I have a field "SumOfQty" in a query that I want to use an IIF statment in
> the criteria: If [Forms]![Zero Qty]![Checkbox] is checked then "SumOfQty"
> criteria is 0.
> else >0.  The 0 works, but it won't see the >0.  What would be the solution
> to get the same results another way?
John Spencer - 31 Aug 2007 12:41 GMT
Add SumOfQtry to the query grid TWO TIMES and then set the criteria as
follows

Field: SumOfQty
Criteria(1): [Forms]![Zero Qty]![Checkbox]=True
Criteria(2):  [Forms]![Zero Qty]![Checkbox]=False

Field: SumOfQty
Criteria(1): 0
Criteria(2): >0

You can't use an IIF statement in a query to set the comparison operator (=,
<, >, etc.), you can only use the IIF statement to decide the values to be
compared.

By the way, when you save the query, Access will rearrange things by moving
[Forms]![Zero Qty]![Checkbox] into a Field "Cell".  You can accomplish the
same thing by doing

Field: [Forms]![Zero Qty]![Checkbox]
Criteria(1): True
Criteria(2): False

Field: SumOfQty
Criteria(1): 0
Criteria(2): >0

I posted the first solution based on a guess that you might have more
criteria than just the one you posted.

Signature

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

>I have a field "SumOfQty" in a query that I want to use an IIF statment in
> the criteria: If [Forms]![Zero Qty]![Checkbox] is checked then "SumOfQty"
> criteria is 0.
> else >0.  The 0 works, but it won't see the >0.  What would be the
> solution
> to get the same results another way?
Sally - 31 Aug 2007 21:02 GMT
John:  That worked perfect!  Boy has that opened up by mind for other
possiblities!  Thanks again for your expert help!

> Add SumOfQtry to the query grid TWO TIMES and then set the criteria as
> follows
[quoted text clipped - 32 lines]
> > solution
> > to get the same results another way?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.