Why do I successfully execute a SQL Statement from the QUERY interface when I execute a SQL Command manually as follows:
I update a user's password temporarily with their userID.
Update tblUserSecurity1 set password = 'zimmer9' Where userID = 'zimmer9'
However, when my Access application executes the following module after the command click event takes place, even though the same SQL Statement is executed, I get the following SQL Error:
Run-time error '-2147217900 (80040e14)': Syntax error in UPDATE statement
Private Sub Command62_Click()
Dim con As ADODB.Connection
Dim cmd As ADODB.Command
Dim strUserID As String
Set con = CurrentProject.Connection
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = con
ComboSelect = Me.Combo55.Column(1)
strUserID = " & ComboSelect & """
cmd.CommandText = "Update tblUserSecurity1 set password = '" & ComboSelect & "' " _
& "Where userID = '" & ComboSelect & "'"
Debug.Print cmd.CommandText
cmd.Execute
End Sub
-----------------------
cmd.CommandText displays the following in the Immediate Window as the result of the Debug.Print statement:
Update tblUserSecurity1 set password = 'zimmer9' Where userID = 'zimmer9'
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.