Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Always Filter Data when opening a Form

Status
Not open for further replies.

obiwanfan

Programmer
Jan 19, 2004
29
US
I have created a Form in Access but I want the data to be filtered by a specific value in one of the fields. Is there a way to have a filter executed upon opening the form without having the user apply the filter?

 
Put this on the OnOpen property of the form:

DoCmd.ApplyFilter "FilterName"

You use an existing query as the filter or write SQL as a string right in your code. If you want to put the query in your code, do this:

Dim SQL as String
SQL = "SELECT blah FROM blah WHERE Blah = blah"
etc...
DoCmd.ApplyFilter SQL

HTH

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top