Results 1 to 2 of 2
  1. #1
    Misterpokey is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2020
    Posts
    8

    FIltered Report based on filtered SubForm

    Good Day,

    Having an issue creating a report based on an existing filter on a subform.

    I have created this form:
    Click image for larger version. 

Name:	Form.jpg 
Views:	10 
Size:	147.0 KB 
ID:	41316

    I have created a report that fulfills my requirements and I am able to program the button to open it. What I cant seem to figure out is how to make my filter on the subform carry over into the report. In the attached screen shot of the form you can see the subform is filtered by the Medical Examiner department. I need the "Open Report" button to open a report that is filtered based off of the search boxes.

    I have gotten my code from other sources but nothing seems to be working:

    Private Sub cmdOpenReport_Click()
    Dim strFilter As String
    strFilter = Me.Form!cbcSearchDepartment.[cbcSearchDepartment]
    Debug.Print strFilter
    If strFilter <> "" Then
    DoCmd.OpenReport "AssetReport", A_PREVIEW, , strFilter
    Else
    MsgBox "Apply a filter to the form first"


    End If


    End Sub



    Am I on the right track with the above code? What am I missing?

    Thanks!

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,469
    On the report, make the record source the table or query that has that data, then in the criteria for that Department column, put Me.Form!cbcSearchDepartment.[cbcSearchDepartment]. Now everytime you open the report, it should filter it by whatever is in the Department combo box field. Take out the strFilter in your button.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Filtered Report from filtered datasheet form
    By gemadan96 in forum Reports
    Replies: 7
    Last Post: 01-03-2014, 05:12 PM
  2. Replies: 12
    Last Post: 05-30-2013, 02:02 PM
  3. Report based on Query but filtered by form
    By michel_annie22 in forum Reports
    Replies: 1
    Last Post: 10-23-2012, 10:40 PM
  4. Open a report based on a filtered list box
    By irish634 in forum Access
    Replies: 5
    Last Post: 02-07-2012, 08:10 AM
  5. Report based of filtered data from a form
    By Fabdav in forum Reports
    Replies: 1
    Last Post: 09-15-2011, 05:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums