Recordset as Recordsource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a recordset which I would like to use as the recordsource of
the report. I can't make the report open using it. Here is the code I am
using:

Set rst = New ADODB.Recordset
DoCmd.OpenReport "rptActsDaily", acViewPreview
Set Reports("rptActsDaily").Recordset = rst

I get an error saying I can't set the recordsource property after the report
has opened. That makes sence so I set the recordsource first and get an error
saying the report is not open. So how do you open a report using a recordset
as the recordsource?
 
Not possible in an .mdb file, even if you try to do it in the Open event of
the report.

Instead, pass the SQL string to the report (if using ACCESS 2002 or 2003) in
the OpenArgs string (or, if using ACCESS 2000 or 97, write the SQL string
into a textbox on the form that is calling the report). Then, in the
report's Open event, get the SQL string (OpenArgs or from textbox) and set
the report's RecordSource property to that SQL string.
 
Back
Top