Transferring the filter from a datasheet form to a report.

A

Avid Fan

I have a datatsheet and a report based on the same query.

I would like to transfer the extra filter to the report as well but it
does not seem to work

I can't seem to access the report's methods and properties from VBA

Me.frmCallReport.Form.Filter gives me the filter.'


rptCallReport.Filter = Me.frmCallReport.Form.Filter
 
D

Douglas J. Steele

Try

Reports!rptCallReport.Filter = Me.frmCallReport.Form.Filter
Reports!rptCallReport.FilterOn = True

Report rptCallReport must be open before you can run this code (so you may
be best off putting it into the report's Open event)
 
A

Avid Fan

Try

Reports!rptCallReport.Filter = Me.frmCallReport.Form.Filter
Reports!rptCallReport.FilterOn = True

Did not work, but gave me a solution

So I tried
Reports!rptCallReport.Filter = Forms!frmCallReport.Form.Filter

(Could someone let me know when you use ! or .)

Did not work.

So in desperation
 
A

Avid Fan

Did not work, but gave me a solution

So I tried
Reports!rptCallReport.Filter = Forms!frmCallReport.Form.Filter

(Could someone let me know when you use ! or .)

Did not work.

So in desperation

Don't know what happened then, last message sent by itself.

Public fred AS string

In the button that opens the report.

fred = Me.frmCallReport.Form.Filter

Private Sub Report_Load()


Reports!rptCallReport.Filter = fred
Me.Report.FilterOn = True

End Sub

There must be a more elegant way of doing it but it works.
 
D

Douglas J. Steele

Sorry about that: I wasn't paying enough attention.

To refer to the form's filter from the report, you need to go through the
Forms collection:

Private Sub Report_Load()

Me.Filter = Forms!NameOfParentForm!frmCallReport.Form.Filter
Me.Report.FilterOn = True

End Sub

For a good discussion of the difference between bang and dot, see what Andy
Baron has at http://doc.advisor.com/doc/05352
 

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