SteveL13
asked on
Syntax error with between dates
Can someone tell me what is wrong with this?
=DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted", = BETWEEN #" & Forms![frmExpiredListingRe portDateRa nge]![txtS tartDate] & "#" AND #" & Forms![frmExpiredListingRe portDateRa nge]![txtE ndDate] & "#")
=DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted", = BETWEEN #" & Forms![frmExpiredListingRe
With between, no need for =.
ASKER
Still getting an error...
"The expression you entered contains invalid syntax"
"The expression you entered contains invalid syntax"
Try:
DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted BETWEEN #" & Forms![frmExpiredListingReportDateRange]![txtStartDate] & "#" AND #" & Forms![frmExpiredListingReportDateRange]![txtEndDate] & "#")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted BETWEEN #" & Forms![frmExpiredListingRe portDateRa nge]![txtS tartDate] & "# AND #" & Forms![frmExpiredListingRe portDateRa nge]![txtE ndDate] & "#")
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![frmExpiredListin gReportDat eRange]![t xtStartDat e], Date()-1) & "# AND #" & NZ(Forms![frmExpiredListin gReportDat eRange]![t xtEndDate] , Date() + 1) & "#")
Just a thought.
DCount("[ExpiredID]", "tblExpiredListings", "SameAgentDateRelisted BETWEEN #" & NZ(Forms![frmExpiredListin
Just a thought.