another syntax error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to update a table based on a record meeting two criteria. I'm
also trying to update the table with the value in a variable but am not
having much luck. Any suggestions would be appreciated. Thanks for the
help. Here is the code I'm trying to use:

Cmd.RunSQL "UPDATE
set[Date] = strC WHERE [Stock Number] = '" &
Me.Units_Field & "' And [Complete] = False"

Im getting a pop up window that says enter parameter value (strC). Not sure
why it is doing this. Thanks again for all of the help...
 
Just as you did with the Stock Number, you need to put the strC variable
outside of the quotes. However, if strC is supposed to be a date, you need
to delimit the date with # characters, and have it in mm/dd/yyyy format (or
some unambiguous format such as dd mmm yyyy or yyyy-mm-dd)

DoCmd.RunSQL "UPDATE
set [Date] = " & _
Format(strC, "\#mm\/dd\/yyyy\#") & _
" WHERE [Stock Number] = '" & _
Me.Units_Field & "' And [Complete] = False"

BTW, Date is a bad choice for a field name: it's a reserved word, and using
it for your own purposes can lead to problems.
 
Back
Top