Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making a copy of the forms recordset using ADO

Status
Not open for further replies.

bakershawnm

Programmer
Apr 18, 2007
84
US
thread705-1477065

I found the linked thread but that doesn't tell me anything really useful.

Does anyone know how to either type cast a DAO recordset as ADO or how to clone the DAO recordset into an ADO set?

I have a great little function, that I got from another source, that will make an actual copy of an ADO recordset (instead of a clone) in memory. But I can't use it for the Form recordset because it is a DAO.

If I could cast the DAO as an ADO that would solve all the issues.

Thanks
 
The two models are completely different, so I believe there is not native method to clone (I may be wrong, but I have never seen it). But I would think it would be relatively easy to write your own class that would do this. I assume you really only care about the fields and the data in the fields. With ADO you can create a disconnected recordset in memory

Then I would think you could just create the needed fields and move the data into the created fields. I imagine similar to the "little function" you have.

I would imagine there is some code out there, but I have never seen it done.

If I have time I will give it a try to see if I can do a demo.
 
not tested

try opening an ADO Connection to the database
Code:
Dim acConn As ADODB.Connection
Dim Rst As ADODB.Recordset
Dim SqlStr As String
Set acConn = New ADODB.Connection
Set Rst = New ADODB.Recordset
acConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CurrentProject.FullName", 3)
Set Rst.ActiveConnection = acConn
Rst.CursorLocation = adUseClient
SqlStr = me.recordsource
Rst.Open SqlStr, acConn

This should give you a ado recordset to the form

let me know how this goes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top