Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100

    Unanswered: Filter Report from List Box on a Form

    I'm trying to filter my report based on a value selected from a list box. This should be fairly straightforward, but I keep getting an error and no data when the report displays.

    PROJ_NAME is what I'm trying to filter on the report.

    This is my code for the button on the form:
    Code:
    Private Sub REPORT_DISPLAY_Click()
    On Error GoTo Err_REPORT_DISPLAY_Click
    
        Dim stDocName As String
        Dim strWhere As String
    
        stDocName = "PROJECT REPORT"
        strWhere = "[PROJ_NAME] = [FORMS].[SELECT_PROJECT].[PROJECT_LIST]"
        DoCmd.OpenReport stDocName, acPreview, WhereCondition:=strWhere
        
    Exit_REPORT_DISPLAY_Click:
        Exit Sub
    
    Err_REPORT_DISPLAY_Click:
        MsgBox Err.Description
        Resume Exit_REPORT_DISPLAY_Click
        
    End Sub
    Any help would be appreciated, thanks.
    BillS

  2. #2
    Join Date
    Jul 2004
    Location
    South Dakota
    Posts
    267
    Another option would be to use the Filter property of the report itself. Place some code in the Report_Open event then set the FilterOn property to True and then set the Filter property to the value you want by referencing the combo/list box on the form.

    Hope that makes sense. If not reply back and I code throw up some code.

    C

  3. #3
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100
    Okay, I turned on the filer and I set the filter to
    Code:
    REPORTS.SELECT_PROJECT.PROJECT_LIST
    which is the list box on the pop-up form.

    What do I use as the event procedure On Open? Thanks!
    BillS

  4. #4
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100
    Finally got it working, thanks.
    BillS

Posting Permissions

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