• Filter a subform (97)

    Author
    Topic
    #386776

    I am trying to use buttons to filter a subform.

    The subform [frmIndicatorDetailsSub] is linked to the main form [frmClients] by the field ClientID. I want to use buttons to filter the field QuarterID on the subform. I already have an unbound field on the main form which updates based on which button is clicked.

    I tried to follow the directions for doing this on a post on the Access Web , but am still stumped. I have limited understanding of code, so I couldn’t completely follow what they were suggesting, and tried to accomplish their alternate suggestion of using a predefined query (I’m assuming this means build the query in the “query” tab of the Database window).

    I successfully created a query [qryChooseQuarter] which does bring up the data, correctly filtered, when [frmClients] is open. But all my efforts to follow their syntax to get the button to apply the query to the subform have failed. I may be missing something, or maybe it is because of the version of Access I am working in (I found that link based on a question on this board from someone using 2000). I’m not wedded to their syntax. Anything that will work will make me happy.

    Hoping to get over this hump! Thank you in advance,
    -cynthia

    Viewing 0 reply threads
    Author
    Replies
    • #672501

      Try something like the following:

      Private Sub cmdFilter_Click()
      Me.frmIndicatorDetailsSub.Form.RecordSource = “qryChooseQuarter”
      End Sub

      Attached to post 132267 you will find a demo Access 97 database that uses combo boxes to filter a subform. If you look at the code behind frmDemo, you will see how the record source of the subform is being changed.

      • #672517

        Thank you. That does it.
        Following the example on Access Web, I had used a ! after the Me, and I did not have quotation marks around my “qryChooseQuarter”.

        But I’ll pat myself on the back for at least having picked the right line from their code to use for syntax!
        Thanks for getting me over the hump. And thanks for the reference to the sample database. I’ve been advised elsewhere on this board that I should be using filters where I am currently using bookmarks, so it’s something I need to understand.
        -cynthia

        • #672524

          Hi Cynthia,

          I’m glad you got that sorted out.

          Bookmarks are often used to locate a specific record within a form, while leaving all records visible. Filters are used to limit the records that are displayed to those satisfying a certain condition, and changing the record source can be used for the same purpose. The latter method has the advantage that the user can’t cancel the filter by accident.

          • #672529

            Thank you again. That is a very nicley clear description of the difference.
            -c

    Viewing 0 reply threads
    Reply To: Filter a subform (97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: