I'm working with a form that displays all records, but has a filter button to
show only a certain year, or all (*). Once prompted for the year in the
messagebox, hitting cancel returns me to the form but with NO records showing.
How can I hit cancel and have it go back to the form, displaying whatever
records it was before hitting the filter button? Here's my current button
code:
------------------------------------------------------------------------------
Private Sub btnFindStyle_Click()
On Error GoTo Err_btnFindStyle_Click
Dim msg, Style, Title, myResponse
msg = "Enter Year (YYYY) to Show, or * to show all:"
Title = "Enter Year"
myResponse = InputBox(msg, Title, "2007")
DoCmd.ApplyFilter , "Year Like '" & myResponse & "'"
Exit_btnFindStyle_Click:
Exit Sub
Err_btnFindStyle_Click:
MsgBox Err.Description
Resume Exit_btnFindStyle_Click
End Sub
---------------------------------------------------------------------------
Thanks!
-Jake
jakeatkins - 20 Jul 2007 21:14 GMT
Still waiting on help on the above ^. Thanks.
-Jake
jakeatkins - 20 Jul 2007 21:14 GMT
Still waiting on help on the above ^. Thanks.
-Jake
Marshall Barton - 20 Jul 2007 23:06 GMT
>I'm working with a form that displays all records, but has a filter button to
>show only a certain year, or all (*). Once prompted for the year in the
[quoted text clipped - 12 lines]
>myResponse = InputBox(msg, Title, "2007")
>DoCmd.ApplyFilter , "Year Like '" & myResponse & "'"
Check myResponse for a zero length string:
If myResponse <> "" Then
DoCmd.ApplyFilter . . .
End If

Signature
Marsh
MVP [MS Access]
jakeatkins - 21 Jul 2007 00:03 GMT
Thanks, a simple fix!!
>>I'm working with a form that displays all records, but has a filter button to
>>show only a certain year, or all (*). Once prompted for the year in the
[quoted text clipped - 7 lines]
> DoCmd.ApplyFilter . . .
>End If