Solved

Syntax error with between dates

Posted on 2016-11-21
6
36 Views
Last Modified: 2016-11-21
Can someone tell me what is wrong with this?

=DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted", = BETWEEN #" & Forms![frmExpiredListingReportDateRange]![txtStartDate] & "#" AND #" & Forms![frmExpiredListingReportDateRange]![txtEndDate] & "#")
0
Comment
Question by:SteveL13
6 Comments
 
LVL 30

Expert Comment

by:hnasr
ID: 41896383
With between, no need for =.
0
 

Author Comment

by:SteveL13
ID: 41896386
Still getting an error...

"The expression you entered contains invalid syntax"
0
 
LVL 30

Expert Comment

by:hnasr
ID: 41896390
Try:
DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted BETWEEN #" & Forms![frmExpiredListingReportDateRange]![txtStartDate] & "#" AND #" & Forms![frmExpiredListingReportDateRange]![txtEndDate] & "#") 

Open in new window

0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 41896392
Perhaps.
=DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted BETWEEN #" & Forms![frmExpiredListingReportDateRange]![txtStartDate] & "# AND #" & Forms![frmExpiredListingReportDateRange]![txtEndDate] & "#")
0
 
LVL 30

Expert Comment

by:hnasr
ID: 41896394
DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted BETWEEN #" & Forms![frmExpiredListingReportDateRange]![txtStartDate] & "# AND #" & Forms![frmExpiredListingReportDateRange]![txtEndDate] & "#")
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 41896416
You might even want to consider something like the following, which includes NZ() function calls to fill in the date parameters if they are empty in the form:

DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted BETWEEN #" & NZ(Forms![frmExpiredListingReportDateRange]![txtStartDate], Date()-1) & "# AND #" & NZ(Forms![frmExpiredListingReportDateRange]![txtEndDate], Date() + 1) & "#")

Just a thought.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

821 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