Solved

iif on a Dcount function

Posted on 2015-02-11
4
162 Views
Last Modified: 2015-02-11
Hello I have the following and trying to figure out how to do an iif  statement

=DCOUNT ("Date","qry")

I want to say iif a field says "30551" then DCount

Thanks
0
Comment
Question by:Ernest Grogg
  • 2
4 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
Comment Utility
=DCOUNT("Date", "qry", "[Field] = '30551'")

or, if [Field] is numeric:

=DCOUNT("Date", "qry", "[Field] = 30551")
0
 
LVL 33

Expert Comment

by:Mike Eghtebas
Comment Utility
Or maybe:

=IsNull(DCOUNT("Date", "qry", "[Field] = 30551"),0)   ' [Field] is numeric

=IsNull(DCOUNT("Date", "qry", "[Field] = '30551'"),0)   ' [Field] is string

Using the solution above.
0
 

Author Closing Comment

by:Ernest Grogg
Comment Utility
Awesome!  


Thanks!
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
@eghtebas,

You don't need to use the NZ() function (IsNull is the SQL Server equivalent) with DCOUNT( ) because it will always return a value, unlike DLOOKUP( ) which could return a NULL and therefore need the NZ( ) function wrapper.

Dale
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now