G
Glint
Hi All,
Please help me out.
Filtering a form with dates in Access will drive me nuts soon. I use this
filter on my form:
If Not IsNull(Ending) And Not IsNull(Starting) Then
Me.Filter = Me.Filter & " And [TDate]>= " & "'" & Format(Starting,
"dd-mmm-yyyy") & "'" & " And [TDate]<=" & "'" & Format(Ending, "dd-mmm-yyyy")
& "'"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
MsgBox "Records filtered according to dates.", vbInformation,
"ECKANKAR AREA ADMIN"
End If
The filter works ERRATICALLY, returning recordsets based on a hidden formula
which I am yet to decode. The problem is that it is the only code that has
returned any recordset at all.
When I use the # sign instead of literal ' sign, it returns no records at
all. If I remove the format(date, "dd-mmm-yyyy"), I get errors or no records.
In fact when I format it any other way (like mm/dd/yyyy), it does not work at
all.
The same code works perfectly without any # or ' sign in another project
like this:
If Not IsNull(Ending) And Not IsNull(Starting) Then
Me.Filter = Me.Filter & " And [TDate]>= Form!Donations!Starting And
[TDate]<=Forms!Donations!Ending"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
MsgBox "Records filtered according to dates.", vbInformation,
"ECKANKAR AREA ADMIN"
End If
The only difference I can see is that the form that does not work is based
on a complex union query (with dates formatted to dd-mmm-yyyy as in the rest
of the project) and this query does work well, while the form that works was
based on tables or a simple query. Could this have accounted for the errors?
WHAT CAN I DO TO GET MY FORM TO FILTER THE UNION QUERY ACCORDING TO DATES?
Please help me out.
Filtering a form with dates in Access will drive me nuts soon. I use this
filter on my form:
If Not IsNull(Ending) And Not IsNull(Starting) Then
Me.Filter = Me.Filter & " And [TDate]>= " & "'" & Format(Starting,
"dd-mmm-yyyy") & "'" & " And [TDate]<=" & "'" & Format(Ending, "dd-mmm-yyyy")
& "'"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
MsgBox "Records filtered according to dates.", vbInformation,
"ECKANKAR AREA ADMIN"
End If
The filter works ERRATICALLY, returning recordsets based on a hidden formula
which I am yet to decode. The problem is that it is the only code that has
returned any recordset at all.
When I use the # sign instead of literal ' sign, it returns no records at
all. If I remove the format(date, "dd-mmm-yyyy"), I get errors or no records.
In fact when I format it any other way (like mm/dd/yyyy), it does not work at
all.
The same code works perfectly without any # or ' sign in another project
like this:
If Not IsNull(Ending) And Not IsNull(Starting) Then
Me.Filter = Me.Filter & " And [TDate]>= Form!Donations!Starting And
[TDate]<=Forms!Donations!Ending"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
MsgBox "Records filtered according to dates.", vbInformation,
"ECKANKAR AREA ADMIN"
End If
The only difference I can see is that the form that does not work is based
on a complex union query (with dates formatted to dd-mmm-yyyy as in the rest
of the project) and this query does work well, while the form that works was
based on tables or a simple query. Could this have accounted for the errors?
WHAT CAN I DO TO GET MY FORM TO FILTER THE UNION QUERY ACCORDING TO DATES?