ADO - Modifying a Recordset with VBA - Where is Recordset.Edit??

J

JDeBeer

Switching from DAO to ADO

I have a table of dates, times, and events. I want to creat a value
in a field based on some logic. Am now learning about ADO and cannot
place a text value in a text field.

Attached is the code. Code compiles fine. Where I get thrown out is
marked with "Not Working".

Error msg "Object or provider is not capable of performing requested
operation"

Thanks for any help.

jdb

=================
Sub OpenRecordSet()
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset

Set conn = CurrentProject.Connection

Set rst = New ADODB.Recordset

'rst.Open "TrendTest", CurrentProject.Connection

rst.Open "tblTrendTest", CurrentProject.Connection
' conn , adOpenDynamic, , adCmdTableDirect

If Not (rst.BOF And rst.EOF) Then
rst.MoveFirst

End If

'Loop through the recordset
Do Until rst.EOF

rst.Fields("PrckDateCycle").Value = "test " ‘NOT WORKING"
rst.Update

rst.MoveNext
Loop

'Close and Destroy recordset
rst.Close

Set rst = Nothing
Set conn = Nothing

Proc_Exit:
Exit Sub

Proc_Err:
MsgBox Err.Description, vbCritical
Resume Proc_Exit

End Sub
 
S

SA

JD

In looking at your code, you appear to have commented out the type of
cursor. You need a dynamic or keyset cursor to support editing.
 
J

John de Beer

Thanks for the pointer. This worked now.

rst.Open "tblTrendTest", conn, adOpenKeyset, adLockOptimistic,
adCmdTableDirect

jdb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top