Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter Using a Date

Status
Not open for further replies.

jdgreen

Technical User
Mar 21, 2001
144
US
I have a very simple database that is a schedule. The key field is the start date of the schedule. I'm trying to open a report with a filter as follows:
Dim stDocName As String
Dim lookupfilter As String

lookupfilter = "[ControlDate]=" & Me![ControlDate]
stDocName = "rptDays"
DoCmd.OpenReport stDocName, acPreview, , lookupfilter

I've used this same format on many other applications and never had a problem. Does it have something to do with it being a date? Am I being dense because it's too late?

John Green
 
It would help if you stated a question in there somewhere. I can only assume you aren't getting any data in the report. If [ControlDate] has a time element then you would need to remove the time element or expand the date range. You might also try:
lookupfilter = "[ControlDate]=#" & Me![ControlDate] & "#"


Duane
MS Access MVP
 
It was too late. I didn't set the default format to just record the date in the table so the time was being recorded so the filter didn't find anything that matched. I was getting just a blank report. Thanks.

John Green
 
Then, you could use
lookupfilter = "DateValue([ControlDate])=DateValue(#" & Me![ControlDate] & "#)"

Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top