
Syntax error in UPDATE statement
Trying to update changes to a record in an Access 2000 Database table using
VB6.
The form uses unbound controls.
I have successfully retrieved the desired record from the database table,
and made changes to the desired fields in the record on the form. Now I'm
trying to update the record in the database with the changes made on the
form.
I'm using an SQL statement and checked the syntax according to the books I
have available. I can't find the problem. Yet when I try to save changes I
get the error "Syntax error in UPDATE statement".
Instead of trying to change the entire record, I am attempting to change
only one field just to keep it simple until I can overcome the problem.
My Access200 database table is: Table2
the record's key field in Access is named: KeyCode
the corresponding control on the VB6 form is: LockCode (same
thing-different name)
the fieldname in Table2 that I'm trying to change is: LastName
the corresponding textbox control & property on the VB6 form is:
txtLastName.text
Here is the code:
Private Sub cmdSave_Click()
'Save Changes to record and clear form
Dim strSQL As String
On Error GoTo HandleErrors
strSQL = "UpDate Table2 " & _
"Set LastName = '" & txtLastName.Text & "', " & _
"Where KeyCode = '" & txtLockCode.Text & "' "
conProjectName1.Execute strSQL
'
'
'
Does anyone see the problem here?