Transferring the filter from a datasheet form to a report.

  • Thread starter Thread starter Avid Fan
  • Start date Start date
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
 
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)
 
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
 
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.
 
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
 
Back
Top