Report filter=form filter

P

Paul Mars

I have a form that has several different record sources. This form has a btn
to open a report. This report has the same record source as the current form
instance. I do this with:

Private Sub Report_Open(Cancel As Integer
Me.RecordSource = Forms!MainData.RecordSource

Now I just filtered the form instance. I thought I could then apply this
filter to the report by adding:

Me.Filter = Forms!MainData.Filter to the above code, but this does not
apply the open form filter to the report. How can I do this?

Thanks,
Paul
 
A

Allen Browne

Did you set FilterOn to true as well?

Private Sub Report_Open(Cancel As Integer)
With Forms!MainData
Me.RecordSource = .RecordSource
If .FilterOn Then
Me.Filter = .Filter
Me.FilterOn = True
End If
End With
End Sub

That should work unless the form's filter has been set by using the
non-bound columns of your combos.

(You might also try saving the report with nothing in its RecordSource
property.)
 
P

Paul Mars

thanks, that did it. Another question: Why did help not tell me this. I
looked up "Filter" and read all there was. Nothing about FilterOn.

Thanks again,
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top