Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Syntax error with between dates

Can someone tell me what is wrong with this?

=DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted", = BETWEEN #" & Forms![frmExpiredListingReportDateRange]![txtStartDate] & "#" AND #" & Forms![frmExpiredListingReportDateRange]![txtEndDate] & "#")
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

With between, no need for =.
Avatar of SteveL13

ASKER

Still getting an error...

"The expression you entered contains invalid syntax"
Try:
DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted BETWEEN #" & Forms![frmExpiredListingReportDateRange]![txtStartDate] & "#" AND #" & Forms![frmExpiredListingReportDateRange]![txtEndDate] & "#") 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted BETWEEN #" & Forms![frmExpiredListingReportDateRange]![txtStartDate] & "# AND #" & Forms![frmExpiredListingReportDateRange]![txtEndDate] & "#")
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.