Update Statement

  • Thread starter Thread starter Tammy Dillon
  • Start date Start date
T

Tammy Dillon

Guest
I am getting a syntax error and I can't spot it... can someone help.

DB.Execute "UPDATE FG-PROD " _
& "SET PACKAGING-CRTN# = " & Me.cboToMstr.Value _
& "WHERE PACKING-LABEL# = "
& Me.cboFromMstr.Value & ";"
 
Hi Tammy,

I think it's one of
1/ It doesn't like your - ( minus )signs and # ( hashes, pounds to you americans...). Which is likely. # are delimiters for date time strings. If you ever need to base a query on a date, you would pass it in as #21/12/00#, or, more likely #12/21/00#. The minus sign is probably just confusing it. If it's now too late to rename your fields ( and that's is worth bareing in mind for future dbs ) then you need to surround the field and table names in [] Your query will then read -

DB.Execute "UPDATE [FG-PROD] " _
& "SET [PACKAGING-CRTN#] = " & Me.cboToMstr.Value _
& " WHERE [PACKING-LABEL#] = "
& Me.cboFromMstr.Value & ";"


2/Having done the above anyway, if your 2 fields are strings ( text ) rather than numbers then you'll need to surround them in "" to get the SQL to work. Your query would then read

DB.Execute "UPDATE [FG-PROD] " _
& "SET [PACKAGING-CRTN#] = " & chr(34) & Me.cboToMstr.Value & chr(34)_
& " WHERE [PACKING-LABEL#] = "
& chr(34) & Me.cboFromMstr.Value & chr(34) & ";"


3/Alternatively the problem may just be that you need a space between the FROM and WHERE clause.

HTH

Drew

[This message has been edited by KDg (edited 10-02-2000).]
 
Hi Drew,
Thanks for the detailed answer. I had to make all the changes you suggested in order for the code to work correctly. It was a big help...THANKS AGAIN!
 

Users who are viewing this thread

Back
Top Bottom