Zoodiaq
asked on
Error 3251 - Trying to edit SQL using VBA code and ADODB connection
I'm trying to edit my SQL but can't find the right method. All I'm getting is an 3251 error. Hope for some help.
Here is the code I'm trying to use:
Here is the code I'm trying to use:
Sub TestWriteSQL()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim ClientID As String
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.ConnectionString = "Provider=sqlncli; Data Source=MYSERVER; Initial Catalog=Test; Trusted_Connection=yes;"
cn.Open
ClientID = 7555
Set rs = cn.Execute("SELECT CustomFieldValue.Value, CustomRecordset.RecordId, CustomFieldValue.CustomFieldId FROM CustomFieldValue INNER JOIN CustomRecordset ON CustomFieldValue.CustomRecordsetId = CustomRecordset.Id WHERE CustomRecordset.RecordId = '" & ClientID & "' And (CustomFieldValue.CustomFieldId = 296)")
'rs.Edit
rs!Value = 22
rs.Update
Set rs = Nothing
cn.Close
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm a beginner in this area. Could you provide me with an example where I change the CustomFieldValue.Value to 22? If I could get that to work I think I could move on from there.