Apply a filter by date not workign

MrTickle

New member
Local time
Today, 18:07
Joined
Aug 30, 2012
Messages
9
Hi

I have a form with an unbound text box for the user to insert a date that will filter all records with this date, but it is not working. The code is based on someone else's code used for a similar function which does work, I just need to make it work in this instance and cannot for the life of me figure out why it won't do what it is supposed to do!

Any help anyone can offer would great. Here is the code:

Private Sub ArrDateSearch_Exit(Cancel As Integer)
' Search for booking using arrival date after exit
If IsNull(ArrDateSearch) Then
GoTo Exit_ArrDateSearch_Exit
Else
On Error GoTo SearchError_Click
Me.Filter = "[Arrival Date] =" & Me.ArrDateSearch
Me.FilterOn = True
Me.Requery
Exit_ArrDateSearch_Exit:
Exit Sub
SearchError_Click:
MsgBox "Insert a valid date"
Resume Exit_ArrDateSearch_Exit
End If
End Sub

The result is that it returns no records, even when I know there are records with the same date input.
 
Send a short example of your table, or your mdb. (Access 2000, or 2002-2003),
and tell what your want to do.
 
You need to use the # sign delimeter around your date

Private Sub ArrDateSearch_Exit(Cancel As Integer)
' Search for booking using arrival date after exit
If IsNull(ArrDateSearch) Then
GoTo Exit_ArrDateSearch_Exit
Else
On Error GoTo SearchError_Click
Me.Filter = "[Arrival Date] = #" & Me.ArrDateSearch & "#"
Me.FilterOn = True
Me.Requery
Exit_ArrDateSearch_Exit:
Exit Sub
SearchError_Click:
MsgBox "Insert a valid date"
Resume Exit_ArrDateSearch_Exit
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom