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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Criteria in Control Source Statement

Status
Not open for further replies.

FrankMars

Technical User
Dec 20, 2010
67
US
I am trying to create a report which only counts the number of records based on a few different criteria. In the control source of a field on the report, I have entered;

=DCount([ID],'[qMain]','[Status] ="Active"') - this returns the correct number of records.

=DCount([ID],'[qMain]','[Price]<1000') - this returns the correct number of records.

When I combine both of these criteria in one statement as follows;

=DCount([ID],'[qMain]','[Status] ="Active"' And '[Price]<1000') - this INCORRECTLY returns ALL records.

Is it possible to write a statement in the control source of a field with multiple criteria? What am I doing wrong?

Thanks in advance.

 
I don't care for using domain aggregate functions in queries or reports. However, you can triy:
Code:
=DCount('[ID]','[qMain]','[Status] ="Active" And [Price]<1000')
or in US
Code:
=DCount("[ID]","[qMain]","[Status] ='Active' And [Price]<1000")
If the record source of the report is qMain then simply use:
Code:
 =Sum(Abs("[Status] ='Active' And [Price]<1000"))

Duane
Hook'D on Access
MS Access MVP
 
Duane - I successfully used your second line of code.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top