Can I use a sub as a reports data source?

  • Thread starter Thread starter DanB
  • Start date Start date
D

DanB

I have a function (although it could be set up as a sub)
that reads a table, does quite a bunch of involved stuff,
then sends out specified fields from selected records to
the immediate window. Can I have these fields go to an
access report instead? Do I need to send the results to
an interim table then the report would use that table for
it's data source? Surely there is a way to send data from
a function or sub directly to a report. I can't get my
report to accept the function as it's source of data.
Someone suggested using
Me.CurrentX = 2000
Me.CurrentY = 1000
Me.Print "This text should display in the report"
But I'm too dense to see how that would send selected
fields to an Access Report.
Thanks in advance for any and all help.
DanB
 
I have a function (although it could be set up as a sub)
that reads a table, does quite a bunch of involved stuff,
then sends out specified fields from selected records to
the immediate window. Can I have these fields go to an
access report instead?

Yes, but you'd need to call it from the report; for example in the Open or
the Format events and so on. You don't have to have a recordsource in a
report (just as a form doesn't have to be bound to a recordset either),
although it's the commonest use.

At bottom, you can simply have a blank page and print on it using code like
the one you have: put it in the Format event, for example.

Hope that helps


Tim F
 
Back
Top