ADODB RecordSet as Access Report RecordSource

烈酒焚心 提交于 2019-12-12 08:48:02

问题


I have a simple form, a query and a report in Access 2003. I have to manipulate the results from the query in a recordset using VBA and then pass it on to the report as its RecordSource.

If I declare the recordset as RecordSet and use its Name property as the RecordSource of the report then it is working. However, because I need to edit the recordset, I though it would be easier to use an ADODB RecordSet as below.

The records set is declared as Dim rs As ADODB.RecordSet in a global module. The rest of the code is;

Dim db As Database
Set db = CurrentDb
Dim con As ADODB.Connection
Set con = CurrentProject.Connection
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = con
rs.Source = "Select * from XXX"
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
rs.Open

'manipulate rs here....'

I used to pass the RecordSource of the report as myReport.RecordSource = rs.Name. But the ADODB doesn't have a Name property.

How can I pass this recordset to the report as its RecordSource?

Thanks


回答1:


You cannot bind a report to an ADO recordset in an mdb, only in an adp: http://support.microsoft.com/?id=287437




回答2:


I don’t have a copy of access 2003 to hand but from memory you just do

Set Me.Recordset = rs

Just had a look on the Microsoft KB and it looks like my memory is still working!

http://support.microsoft.com/kb/281998



来源:https://stackoverflow.com/questions/4184871/adodb-recordset-as-access-report-recordsource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!