Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Filter Form Records button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jakeatkins - 19 Jul 2007 17:53 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
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.