-1

I am getting the above error whilst running this commmand:

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

Can anyone explain why?

Thanks!

Harshana Narangoda
  • 775
  • 1
  • 8
  • 23
user2799788
  • 103
  • 1
  • 4
  • 13
  • 3
    Are those values coming from textboxes? If so, you need the `.text` identifier on the end of the textbox name. – The Blue Dog Apr 26 '14 at 16:20
  • 1
    -1 This is the second question you've tagged with both mysql and ms-access. Do not use inappropriate tags for your questions. – John Conde Apr 26 '14 at 16:23

1 Answers1

1

I think your problem is in the FirstName value. It seems to be a string and so you need to put your value inside single quotes

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

Said that, please read about Sql Injection and Parameterized queries. Your code, as is, it is very weak and could fail simply if someone types a LastName like O'Malley (the single quote breaks your string concatenation)

As pointed by a comment above, I suppose that these variables are not TextBoxes but just string variables. If these are TextBoxes then, the value to set the field to comes from the Text property of the TextBox. Something like

" SET FirstName='" & Me.frst_Name_txt.Text & "'" 
Community
  • 1
  • 1
Steve
  • 213,761
  • 22
  • 232
  • 286