Good Day,
Having an issue creating a report based on an existing filter on a subform.
I have created this form:
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!