theinviter
Registered User.
- Local time
- Today, 08:07
- Joined
- Aug 14, 2014
- Messages
- 240
Dears;
I have a sub form that contain Date Filter filed ( Date_From and Date_To). so i tried to filter the form with below code and work fine.
but i clear the filter by clicking on button, got error message " The Search key was not found in any record"
so how to avoid this error.
Private Sub filterThisForm2()
Dim Filter As String
If IsNull(Me.Date_From) Or IsNull(Me.Date_To) Then
Me.FilterOn = False
Else
Filter = "[Date_] BETWEEN #" & Format(Me.Date_From, "yyyy\/mm\/dd") & "# AND #" & Format(Me.Date_To, "yyyy\/mm\/dd") & "#"
' Print the filter string to the Immediate window (press Ctrl+G).
Debug.Print Filter
Me.Filter = Filter
Me.FilterOn = True
End If
End Sub
Private Sub Clear_Click()
Date_From = ""
Date_To = ""
Call filterThisForm2
End Sub
I have a sub form that contain Date Filter filed ( Date_From and Date_To). so i tried to filter the form with below code and work fine.
but i clear the filter by clicking on button, got error message " The Search key was not found in any record"
so how to avoid this error.
Private Sub filterThisForm2()
Dim Filter As String
If IsNull(Me.Date_From) Or IsNull(Me.Date_To) Then
Me.FilterOn = False
Else
Filter = "[Date_] BETWEEN #" & Format(Me.Date_From, "yyyy\/mm\/dd") & "# AND #" & Format(Me.Date_To, "yyyy\/mm\/dd") & "#"
' Print the filter string to the Immediate window (press Ctrl+G).
Debug.Print Filter
Me.Filter = Filter
Me.FilterOn = True
End If
End Sub
Private Sub Clear_Click()
Date_From = ""
Date_To = ""
Call filterThisForm2
End Sub