cjohnson78
Registered User.
- Local time
- Yesterday, 23:47
- Joined
- Mar 29, 2012
- Messages
- 11
I need help please. I can't figure out how to UPDATE a record in
Access 2010 using an Excel 2010 userform.
Run-time error '3709':
The connection cannot be used to perform this operation.
It is either closed or invalid in this context.
Dim Cn As ADODB.Connection, _
Rs As New ADODB.Recordset, _
oCm As ADODB.Command, _
iRecAffected As Integer
On Error GoTo ADO_ERROR
Set Cn = New ADODB.Connection
Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Chris Johnson\My Documents\SCID Base.accdb;Persist Security Info=False"
Set Rs = New ADODB.Recordset
Rs.CursorType = adOpenKeyset
Rs.LockType = adLockOptimistic
Rs.Open "SELECT * [Technican_Name] FROM [Service Board] WHERE [Technician_Name].Text = ' & Call Holding 1 & '"
With Rs
Rs.Fields(1).Value = frmQueServiceCall.txtDateReceived.Value
Rs.Fields(2).Value = frmQueServiceCall.txtTimeReceived.Value
.Update
End With
oCm.Execute iRecAffected
If iRecAffected = 0 Then
MsgBox "No records inserted"
End If
Application.StatusBar = False
If Not oCm Is Nothing Then Set oCm = Nothing
If Not Cn Is Nothing Then Set Cn = Nothing
If Not Rs Is Nothing Then Set Rs = Nothing
ADO_ERROR:
If Err <> 0 Then
MsgBox Err.Description
Err.Clear
Resume Next
End If
End Sub
Thank you in advance to any that reply.
Ok so I added Rs.ActiveConnection = Cn to my code but now i get a new error.
Run-time error '-214721790(8004e14)':
syntax error(missing operator)in query expression'*[Technician_Name]'
Access 2010 using an Excel 2010 userform.
Run-time error '3709':
The connection cannot be used to perform this operation.
It is either closed or invalid in this context.
Dim Cn As ADODB.Connection, _
Rs As New ADODB.Recordset, _
oCm As ADODB.Command, _
iRecAffected As Integer
On Error GoTo ADO_ERROR
Set Cn = New ADODB.Connection
Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Chris Johnson\My Documents\SCID Base.accdb;Persist Security Info=False"
Set Rs = New ADODB.Recordset
Rs.CursorType = adOpenKeyset
Rs.LockType = adLockOptimistic
Rs.Open "SELECT * [Technican_Name] FROM [Service Board] WHERE [Technician_Name].Text = ' & Call Holding 1 & '"
With Rs
Rs.Fields(1).Value = frmQueServiceCall.txtDateReceived.Value
Rs.Fields(2).Value = frmQueServiceCall.txtTimeReceived.Value
.Update
End With
oCm.Execute iRecAffected
If iRecAffected = 0 Then
MsgBox "No records inserted"
End If
Application.StatusBar = False
If Not oCm Is Nothing Then Set oCm = Nothing
If Not Cn Is Nothing Then Set Cn = Nothing
If Not Rs Is Nothing Then Set Rs = Nothing
ADO_ERROR:
If Err <> 0 Then
MsgBox Err.Description
Err.Clear
Resume Next
End If
End Sub
Thank you in advance to any that reply.
Ok so I added Rs.ActiveConnection = Cn to my code but now i get a new error.
Run-time error '-214721790(8004e14)':
syntax error(missing operator)in query expression'*[Technician_Name]'
Last edited: