Solved

DCount with multiple criteria

Posted on 2016-11-21
3
48 Views
Last Modified: 2016-11-21
What is wrong with:

=DCount("[ExpiredID]","tblExpiredListings","DiffAgentDateRelisted BETWEEN #" & [Forms]![frmExpiredListingReportDateRange]![txtStartDate] & "# AND #" & [Forms]![frmExpiredListingReportDateRange]![txtEndDate] & "#" & " AND [ListingAgent] = '" John Doe "'")
0
Comment
Question by:SteveL13
3 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 250 total points
ID: 41896453
Your're missing some ampersands.  If you always want it to be John Doe, why not:

=DCount("[ExpiredID]","tblExpiredListings","DiffAgentDateRelisted BETWEEN #" & [Forms]![frmExpiredListingReportDateRange]![txtStartDate] & "# AND #" & [Forms]![frmExpiredListingReportDateRange]![txtEndDate] & "#" & " AND [ListingAgent] = 'John Doe'")
0
 
LVL 19

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 125 total points
ID: 41896462
you can combine your literals -- you also have an extra quote mark and spaces'
=DCount("[ExpiredID]","tblExpiredListings","DiffAgentDateRelisted BETWEEN #" & [Forms]![frmExpiredListingReportDateRange].[txtStartDate] & "# AND #" & [Forms]![frmExpiredListingReportDateRange].[txtEndDate] & "# AND [ListingAgent] = 'John Doe'")

Open in new window

 I like to use . instead of ! when referring to controls.
0
 
LVL 33

Assisted Solution

by:Norie
Norie earned 125 total points
ID: 41896464
Try this.

=DCount("[ExpiredID]","tblExpiredListings","DiffAgentDateRelisted BETWEEN #" & [Forms]![frmExpiredListingReportDateRange]![txtStartDate] & "# AND #" & [Forms]![frmExpiredListingReportDateRange]![txtEndDate] & "# AND [ListingAgent] = 'John Doe '")
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

789 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