Microsoft 365 and Office | Excel | Other | Windows
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Dear all,
I have built this VBA function but I'm getting the below error (see the next screenshot) in the bold portion of the code:
Public Sub UserLogoutDetail(UserEmail As String)
Dim MySQL As String
Dim RstUserAccess As New ADODB.Recordset
Dim CmdUserAccess As New ADODB.Command
Dim i As Integer
'Setup the command
Set CmdUserAccess.ActiveConnection = fGetConn
CmdUserAccess.CommandType = adCmdText
MySQL = "UPDATE User_Access_TABLE SET EXIT_DATA = #" & Now & "# WHERE (((ID)=" & GetID_ToUpdate(UserEmail) & "))"
CmdUserAccess.CommandText = MySQL
RstUserAccess.CursorLocation = adUseClient
RstUserAccess.CursorType = adOpenDynamic
RstUserAccess.LockType = adLockOptimistic
'Open the connection
RstUserAccess.Open CmdUserAccess
Set RstUserAccess.ActiveConnection = Nothing
RstUserAccess.Close
'Cleanup
If CBool(CmdUserAccess.State And adStateOpen) = True Then
Set CmdUserAccess = Nothing
End If
If CBool(fGetConn.State And adStateOpen) = True Then
CloseConn
End If
End Sub
Do you have any suggestion?
Thanks
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Remove that line too.
Why don't you follow my suggestion to do away with the recordset and use the Execute method of the Command object?