user2799788
user2799788

Reputation: 103

Syntax error in the below update command

Could someone please tell me where I am going with the syntax in this update command?

CurrentDb.Execute "UPDATE VolunteerDetails" & "SET FirstName=" & Me.frst_Name_txt & ", LastName='" & Me.lst_Name_txt & "'" & " WHERE VolsID=" & Me.vol_ID_txt

Thanks!

I have tried it a new way, to make it simpler....but is still giving me a syntax error.

CurrentDb.Execute "UPDATE VolunteerDetails SET FirstName=Me.frst_Name_txt, LastName=Me.lst_Name_txt, WHERE VolsID=Me.vol_ID_txt"

Upvotes: 2

Views: 72

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500055

Your SQL will look something like:

UPDATE VolunteerDetailsSET FirstName=Foo, LastName='Bar' WHERE VolsID=10

Three problems with this:

  • You have no space between VolunteerDetails and SET
  • You have no apostrophes around the first name to quote it
  • You shouldn't be including the values directly in your SQL at all (as you have a SQL injection vulnerability)

It's not clear what language you're using (VB? just straight Access forms?) but you should definitely use parameterized SQL. If you can give us more data about your environment, we can help you more.

Upvotes: 5

Related Questions