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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter Command

Status
Not open for further replies.

achiola

MIS
Apr 26, 2001
44
US
I desperately need a visual basic code to write a filter command. I want to click a command button and have it filter a form under a specified criteria. Can anyone help?

Nino
 
When you say a specified criteria will it always be the same? Life's a journey enjoy the ride...

jazzz
 
Yes...exactly. I want to click the command button and always filter the form by only one criteria... that criteria is "Open".

Nino
 
OK try something like this.

on the click event of your control
add this.

Dim strfilter as String
strfilter = "Open"

DoCmd.OpenForm "Myform", , , "myfieldbasedonOpen = " & strfilter

Hope this at least points you in the right direction.
Life's a journey enjoy the ride...

jazzz
 
Jazz,
It almost works... the problem is, my actual criteria is "a-open". When I put this into the code above a msgbox appears first with the letter "a" then another with "open". If I use the word "Open", then that word appears and I could type in my criteria "a-open" and it would work. Except I need it to automatically filter with just one click. Any ideas?

Nino
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top