how to set a filter on a open form in microsoft access 2013 with vba

i have an open form and i want that when i press some command it's will filter the form to show only records that the price is 150 how i set this with vba

something like this :
Me.Filter = "[price] = 150
  Me.FilterOn = True

thanks
bill201Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Is that your exact code? Is so, there's some syntax issues:

Me.Filter = "price=150"
Me.FilterOn = True

If you're doing this from another form, you must refer to the form:

Forms("YourFom").Filter = "Price=150"
Forms("YourForm").FilterOn = True

Also, if you're dealing with a Subform, you'll have different syntax, so let us know.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bill201Author Commented:
thanks for your answer, it's was another syntax issue,thanks alot
0
bill201Author Commented:
excellent thanks alot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.