Help! Filter by Date

  • Thread starter Thread starter Russell Farr
  • Start date Start date
R

Russell Farr

Hi

I have a list of advertisements in a continuous form, and
I want to filter by 3 dates - this Friday, the previous
Friday, or next Friday.

I have used the Weekday() function to determine the day of
the week and adjusted the date accordingly. I have 3
buttons to filter by each Friday, and assign the filter as
[FridaysDate], [FridaysDate]+7, [FridaysDate]-7.

However, it seems to only want to filter on the previous
Friday's date.

The line I am using is:

[FridaysDate]=[FridaysDate]+7 (or -7, or nothing at all)
Me.Filter = "[InitialAdDate]=#" & [FridaysDate] & "#"

I then tried specifying the date in the code as:

Me.Filter = "[InitialAdDate]=#05/03/04#"

but this doesn't work either!

Is this a common issue with Access and dates filtering?

Thanks

Russell
 
The line I am using is:

[FridaysDate]=[FridaysDate]+7 (or -7, or nothing at all)
Me.Filter = "[InitialAdDate]=#" & [FridaysDate] & "#"

I'd suggest

Me.Filter = "[InitialAdDate] =" & Format(DateAdd("d", <expression>,
[FridaysDate]),"\#mm/dd/yyyy\#")

where the expression returns -7, 0 or 7. A date must be in
month/day/year format and your system settings might be using
something different; the explicit Format will help.
 
Back
Top