I have a form that filters data by the DemoClientID to the subform. When a Client is selected on the form it brings up all the records for that Client in the subform. I have created a report that contains all the data I want to display and I have created a button to open that report. I want the report to filter off the DemoClientID that is on the from. This is the VBA code I have created but it doesn't filter by the DemoClientID. I brings up all the records. Can anyone tell me what I am doing wrong?
Code:
Private Sub cmdCurrent_Click()
If Me.FilterOn And InStr(Me.Filter, "DemoClientID = " & Me!DemoClientID) > 0 Then
DoCmd.OpenReport "rptVendorPayment", acViewPreview, , Me.Filter
Else
DoCmd.OpenReport "rptVendorPayment", acViewPreview
End If
Exit_Preview_report_Click:
Exit Sub
End Sub