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.
 

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


Back
Top