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

Posted on 2014-07-14
Last Modified: 2014-07-14
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

Question by:bill201
    LVL 84

    Accepted Solution

    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.

    Author Comment

    thanks for your answer, it's was another syntax issue,thanks alot

    Author Closing Comment

    excellent thanks alot

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now