P
Panos
Hi everyone
I have a form with an option group that filters records for the past 1,3,6
and 12 months.
I'm using the format dd/mm/yyyy for my dates. Access at some point is
swapping the day and month parts to the American format mm/dd/yyyy. But only
if the day could be a month as well ie: if the day is less than or equal to
12. This is causing filters for the first twelve days of a month to be
invalid or for the wrong records to be returned
My Regional Settings in Control Panel are dd/mm/yyyy so no issue there.
Any answers for this cause i'm really stuck...
---Code---
Private Sub optFilterMonths_AfterUpdate()
Dim strwhere As Variant
Select Case Me.optFilterMonths
Case Is = 1
strwhere = DateAdd("m", -1, Date)
DoCmd.ApplyFilter , "[LessonDate] >= #" & DateValue(strwhere) & "# And
[LessonDate] <= #" & DateValue(Date) & "#"
Me.FilterOn = True
Case Is = 2
strwhere = DateAdd("m", -3, Date)
DoCmd.ApplyFilter , "[LessonDate] >= #" & DateValue(strwhere) & "# And
[LessonDate] <= #" & DateValue(Date) & "#"
Me.FilterOn = True
Case Is = 3
strwhere = DateAdd("m", -6, Date)
DoCmd.ApplyFilter , "[LessonDate] >= #" & DateValue(strwhere) & "# And
[LessonDate] <= #" & DateValue(Date) & "#"
Me.FilterOn = True
Case Is = 4
strwhere = DateAdd("yyyy", -1, Date)
DoCmd.ApplyFilter , "[LessonDate] >= #" & DateValue(strwhere) & "# And
[LessonDate] <= #" & DateValue(Date) & "#"
Me.FilterOn = True
Case Is = 5
Me.FilterOn = False
End Select
End Sub
---Code---
ThanKs in Advance
I have a form with an option group that filters records for the past 1,3,6
and 12 months.
I'm using the format dd/mm/yyyy for my dates. Access at some point is
swapping the day and month parts to the American format mm/dd/yyyy. But only
if the day could be a month as well ie: if the day is less than or equal to
12. This is causing filters for the first twelve days of a month to be
invalid or for the wrong records to be returned
My Regional Settings in Control Panel are dd/mm/yyyy so no issue there.
Any answers for this cause i'm really stuck...
---Code---
Private Sub optFilterMonths_AfterUpdate()
Dim strwhere As Variant
Select Case Me.optFilterMonths
Case Is = 1
strwhere = DateAdd("m", -1, Date)
DoCmd.ApplyFilter , "[LessonDate] >= #" & DateValue(strwhere) & "# And
[LessonDate] <= #" & DateValue(Date) & "#"
Me.FilterOn = True
Case Is = 2
strwhere = DateAdd("m", -3, Date)
DoCmd.ApplyFilter , "[LessonDate] >= #" & DateValue(strwhere) & "# And
[LessonDate] <= #" & DateValue(Date) & "#"
Me.FilterOn = True
Case Is = 3
strwhere = DateAdd("m", -6, Date)
DoCmd.ApplyFilter , "[LessonDate] >= #" & DateValue(strwhere) & "# And
[LessonDate] <= #" & DateValue(Date) & "#"
Me.FilterOn = True
Case Is = 4
strwhere = DateAdd("yyyy", -1, Date)
DoCmd.ApplyFilter , "[LessonDate] >= #" & DateValue(strwhere) & "# And
[LessonDate] <= #" & DateValue(Date) & "#"
Me.FilterOn = True
Case Is = 5
Me.FilterOn = False
End Select
End Sub
---Code---
ThanKs in Advance