Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DCount, how do I have multiple conditions

Status
Not open for further replies.

Triacona

Technical User
Jun 11, 2009
462
0
0
GB
Dear All,

I have a problem, I have a report which runs off a few queries.

Instead of creating 14 more queries I thought to use the DCount Function to enable me to use the queries to the best of my ability.
That worked fine when I used:

Code:
=DCount("REFVAL","SrNoiseCmplCount","[SRNOICAT]='INDUST'")
The above worked fine when I only had to look for catefories.

I then needed to count via categories and outcomes.

This opened a can of worms, because I can have categories without outcomes.

I tried the DCount function as below and it gave me an #Error
Code:
=DCount("REFVAL","SrNoiseOutCome","IIf([SRNOIOUT]='NUICEA',IIf([SRNOICAT]='INDUST'),0)")
How do I use DCount to set multiple criteria?

Thank you for your forthcoming help [smile]



Thank you,

Kind regards

Triacona
 
Hi,
I looked in the help file and found an example that helped and I used it in my problem...

But it gives the total number in the query 168 rather that 0 which is what this would give if you entered the criteria in the query

Code:
=DCount("REFVAL","SrNoiseOutCome","[SRNOIOUT]='NUICEA'" And "[SRNOICAT]='INDUST'")

Any help would be greatly appreciated[bigsmile]

Thank you,

Kind regards

Triacona
 
I have figured it out yay!

The CORRECT CODE is below.
Code:
=DCount("REFVAL","SrNoiseOutCome","[SRNOICAT]='INDUST' And [SRNOIOUT]='NUICEA'")

INCORRECT CODE:
Code:
DCount("REFVAL","SrNoiseOutCome","[SRNOIOUT]='INDUST'[red]"[/red] And [red]"[/red][SRNOICAT]='NUICEA'")
YAY! [bigsmile]

Thank you,

Kind regards

Triacona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top