update Query

C

Chris

Hi All. I'm trying to write an update query to run in the on click event of
a command button when a first name is changed via a form.

Dim strSQLStaff
Dim strFName As String

strFName = Me.txtFname
strSQLStaff = "Update tblStaff " & _
"Set Fname = " & strFName & _
" where staffID =" & Me.cboStaff & ";"
DoCmd.RunSQL strSQLStaff

I'm getting the error;

runtime error '3075'
syntax error (missing operator)in query expression 'John'

any idea's?
 
D

Duane Hookom

You must add in the text delimiters:
Dim strSQLStaff
Dim strFName As String

strFName = Me.txtFname
strSQLStaff = "Update tblStaff " & _
"Set Fname = """ & strFName & _
""" where staffID =" & Me.cboStaff & ";"
DoCmd.RunSQL strSQLStaff

If the StaffID is text, you will need to modify and add the quotes.
 

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

Top