Report Controlsource

G

Graham Payton

Hi


I have a report that I wish to populate from a recordset.

In the report I have put some code into the On Open event.

This basically runs a stored procedure and populates a recordset that I
have. I then want to make this recordset the source for the report. I
tried the following, but it didn't work.

Me.ControlSource = rstTodaysData

Can anyone tell me how to get my report to run from my recordset?


Thanks in advance


Graham
 
F

Fredg

Graham,
Reports don't have a ControlSource property,
they have a RecordSource.

Me.RecordSource = Whatever....
 
G

Graham Payton

Hi Fred


Sorry, I made a typo there.

I did mean RecordSource.

But that won't work when I point it to a recordset.

The following code comes up with a "Compile Error: Type Mismatch" error when
you try to open the report.

strTodaysPapers = "Saturday"

Set cnn = CurrentProject.Connection
Set cmdSQL.ActiveConnection = cnn
cmdSQL.CommandText = "GetTodaysPapers '" & strTodaysPapers & "'"
Set rstTodaysPapers = cmdSQL.Execute()

With rstTodaysPapers
.MoveLast
.MoveFirst
End With

Me.RecordSource = rstTodaysPapers

Any ideas why?

Thanks


Graham
 

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