• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 641
  • Last Modified:

Access VBA ADO recordset problem


I'm using ADO to load a dynamic recordset to a form.

It works okay except when I set the forms recordset to the recordset returned via ADO it is read-only.   I need the form fields to be editable as I'm using a SQL Server Stored proc to update the table.

Any ideas?

I've attached the code below.

Code behind form :


Public Sub LoadClient(ClientId As Integer)

If Not Me.Recordset Is Nothing Then
End If

Dim sql As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim clDA As New ClientDA
sql = "some sql"
Set rs = clDA.GetRecordSet(sql)
Set Me.Recordset = rs
Set rs = Nothing
Set cn = Nothing
Set clDA = Nothing

End Sub


The clDA class is listed below :


Public Function GetRecordSet(sql As String) As ADODB.Recordset

   Dim rs As ADODB.Recordset
   'Create an instance of the ADO Recordset class, and
   'set its properties
   Set rs = New ADODB.Recordset
   With rs
      Set .ActiveConnection = cnn
      .Source = sql
      .LockType = adLockOptimistic
      .CursorType = adOpenKeyset
   End With
   Set GetRecordSet = rs

End Function


The connection string is :


Public Const CNN_STR = "DRIVER=SQL

Public Const CNN_PRV = "Microsoft.Access.OLEDB.10.0"

Any ideas?
1 Solution
Try using rs.clone

Me.Recordset = rs.clone()
Which version of Access?  From (maybe faulty) memory I think you need at least A2003 for the data to be updateable.
Rey Obrero (Capricorn1)Commented:
see the method use from this link

How to use ADO disconnected and persisted recordsets
lee_jdAuthor Commented:
I'm run Access 2010 and querying SQL Server 2008 R2.

I tried rs.clone() but it had no effect.
Rey Obrero (Capricorn1)Commented:
did you look at the method from the link i posted ?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now