• Filter report based on selection on Form

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Filter report based on selection on Form

    Author
    Topic
    #475971

    I have a form that lists the status of a set of projects. I am trying to allow the user to click on the form field for the project name to see the detailed records for the selected project. I have it set to open the report, but can’t figure out how to limit the data to just the selected project.

    Viewing 0 reply threads
    Author
    Replies
    • #1275224

      The OpenReport command accepts a “Where” clause that limits the report to the condition specified.

      Here is an example

      Code:
      Dim strDocname  as string
      Dim strCriteria as string
      
      strDocname =”rptYourReport”
      strCriteria = “[ProjectID]=” me.[projectID]
      DoCmd.OpenReport strDocName, acPreview, , strCriteria

      This assumes that projects are identifed by a numerical ProjectID.

      If the unique identifier for a project was its name you would use:
      strCriteria =”[ProjectName]=” & chr(34) & me.[projectname] & chr(34)
      chr(34) is just code for a double quote.

    Viewing 0 reply threads
    Reply To: Reply #1275224 in Filter report based on selection on Form

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

    Your information:




    Cancel