By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,349 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,349 IT Pros & Developers. It's quick & easy.

Provide a Recordset to a report from VB via COM API?

P: n/a

I have a situation where I would like to prepare a Recordset object
within Visual Basic (6.0), and then use the MS Access COM API's to
Show a report built off of the data in my Recordset (e.g. NOT letting
MS Access get its own data through its normal Tables, SQL statements,

I tried the following code:

Set rs = CreateObject("ADODB.Recordset")
' fill in my recordset with some valid data
Set mdb = CreateObject("Access.Application")
mdb.OpenCurrentDatabase("C:\Path\To\My.mdb", False)
mdb.Visible = True
mdb.DoCmd.OpenReport("RptName", acViewDesign)
Set mdb.Reports("RptName").Recordset = rs
mdb.DoCmd.OpenReport("RptName", acViewPreview)

and am seeing the following error on the next-to-last line:

"You can't assign a value to this object."

I tried using an .ADP file as well, but to no avail.

I ran across one suggestion of opening a recordset (within Access
Macro code though, which I'd prefer to avoid), and then setting
Report.recordSource = rs.Name inside the Report_Open event. I'd try
this approach, but I can't figure any way to provide my RS to a valid
global variable within MSAccess (that the Report_Open event proc could

Thanks in advance for any assistance, or pointers to a working sample,

- Kevin
Nov 13 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.