Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jan 2008
    Location
    Naperville, Illinois, United States
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Filter report based on selection on Form

    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.

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    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.
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •