Create a disconnected ADO recordset on current db

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

Guest

I am using Office 2003 on Windows XP.

Does anyone know how to create a disconnected ADO recordset on the CurrentDB?

If so could you please post example code? (I would post what I have worked
on, but it doesn't work anyway...)

Thanks much in advance.
 
Just open the recordset with a valid connection, then remove the connection.

'Instantiate the recordset
Set rs = New ADODB.Recordset

'Give it a client-side cursor, and set its attributes
rs.CursorLocation = adUseClient
rs.LockType = adLockBatchOptimistic
rs.CursorType = adOpenKeyset

'Open the recordset, getting its data from the database
rs.Open "Customers", strConnectionString

'Now disconnect the recordset
Set rs.ActiveConnection = Nothing


' To update the data, make some changes, then reconnect it to the datasource
rs.ActiveConnection = CurrentProject.Connection

'Update the data
rs.UpdateBatch

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
(Currently in Japan)
 
I don't know if you asian lanuages installed on your PC, but...
????????
:-)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
(Currently in Japan)
---------------------------
 
For some reason the Kanji didn't come out (even on my PC). Oh well. :-)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
(Currently in Japan)
---------------------------
 
Hello Graham,

I'm headed out the door but will check for replies later:

Sorry, no, I don't have Asian installed, but I would love to visit Japan
sometime.
Thanks again for your help.

FYI, I put my own fingerprints on it by building a function that returns a
recordset clone. That way I can close the original connection while
working with the data (couldn't have done it without you) works great:

Private Function AccessSideADODisconnectedRecordset(argSQL As String) As
ADODB.Recordset
'RETURN AN ACCESS-SIDE ADO DISCONNECTED RECORDSET ON THE CURRENT DB
Set rsADO = New ADODB.Recordset
rsADO.CursorLocation = adUseClient
rsADO.LockType = adLockBatchOptimistic
rsADO.CursorType = adOpenKeyset
rsADO.Open argSQL, CurrentProject.Connection
Set rsADO.ActiveConnection = Nothing 'sever the connection
Set AccessSideADODisconnectedRecordset = rsADO.Clone 'return a clone
rsADO.Close
Set rsADO = Nothing
End Function

Lakeland, Florida USA
 
Back
Top