Syntax Error in Update Statement

K

krisjuchau

I believe the Syntax is correct, but it keeps throwing a syntax error.
Any help would be appreciated.


Private Sub cmdSubmit_Click()

Dim strUpdateSQL As String

With Me
strUpdateSQL = _
" UPDATE tblDevelop SET " & _
" [CustName] = " & """" & .txtName & """," & _
" [Q1S] = " & """" & .txtQ1 & """," & _
" [Q2S] = " & """" & .txtQ2 & """," & _
" [Q3S] = " & """" & .txtQ3 & """," & _
" [Q4S] = " & """" & .txtQ4 & """," & _
" [Q5S] = " & """" & .txtQ5 & """," & _
" [Q6S] = " & """" & .txtQ6 & """," & _
" [Q7S] = " & """" & .txtQ7 & """," & _
" [Q8S] = " & """" & .txtQ8 & """," & _
" [Q9S] = " & """" & .txtQ9 & """," & _
" [Q10S] = " & """" & .txtQ10 & """," & _
" [Q11S] = " & """" & .txtQ11 & """," & _
" [Q12S] = " & """" & .txtQ12 & """," & _
" [Q13S] = " & """" & .txtQ13 & """," & _
" [Q14S] = " & """" & .txtQ14 & """," & _
" [TYPE] = " & """" & .txtType & """," & _
" [CustComp] = " & """" & .txtCust & """," & _
" WHERE tblDevelop.DevID = " & """" & .txtDevID & """"
End With

CurrentDb.Execute strUpdateSQL, dbFailOnError

MsgBox "Thank You"

End Sub
 
D

Dirk Goldgar

I believe the Syntax is correct, but it keeps throwing a syntax error.
Any help would be appreciated.


Private Sub cmdSubmit_Click()

Dim strUpdateSQL As String

With Me
strUpdateSQL = _
" UPDATE tblDevelop SET " & _
" [CustName] = " & """" & .txtName & """," & _
" [Q1S] = " & """" & .txtQ1 & """," & _
" [Q2S] = " & """" & .txtQ2 & """," & _
" [Q3S] = " & """" & .txtQ3 & """," & _
" [Q4S] = " & """" & .txtQ4 & """," & _
" [Q5S] = " & """" & .txtQ5 & """," & _
" [Q6S] = " & """" & .txtQ6 & """," & _
" [Q7S] = " & """" & .txtQ7 & """," & _
" [Q8S] = " & """" & .txtQ8 & """," & _
" [Q9S] = " & """" & .txtQ9 & """," & _
" [Q10S] = " & """" & .txtQ10 & """," & _
" [Q11S] = " & """" & .txtQ11 & """," & _
" [Q12S] = " & """" & .txtQ12 & """," & _
" [Q13S] = " & """" & .txtQ13 & """," & _
" [Q14S] = " & """" & .txtQ14 & """," & _
" [TYPE] = " & """" & .txtType & """," & _
" [CustComp] = " & """" & .txtCust & """," & _
" WHERE tblDevelop.DevID = " & """" & .txtDevID & """"
End With

CurrentDb.Execute strUpdateSQL, dbFailOnError

MsgBox "Thank You"

End Sub


You don't want the trailing comma after .txtCust in this line:
" [CustComp] = " & """" & .txtCust & """," & _

It should be:

" [CustComp] = " & """" & .txtCust & """" & _

Are all those fields, including DevID, really text fields?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Update/Insert Statement 6

Top