1

I am trying to update several columns in a table called "tbl_Responses" but it gives an error after running which I have been trying to find!

varX= DLookup("[ID]", tableName, "[supplierNum] = " & supplierNum)
updateFieldsTbl1="column1,column2,column3,column4"
updateValuesTbl1 ="name,lastname, bla bla"
'There is nothing wrong with those 3 variables above.


sqlUp = "UPDATE " & tableName & "(" & updateFieldsTbl1 & ")" & " SET " & "(" & _ updateValuesTbl1 & ") WHERE ID = " & varX
DoCmd.RunSQL sqlUp

It gives an error in UPDATE statement line. Can you please tell what I am doing wrong? Thanks in advance

0

2 Answers 2

2

Your string parses to:

UPDATE tableName (column1,column2,column3,column4) SET (name,lastname, bla bla) ...

Which is similar to the INSERT format which is not valid for an UPDATE, the correct format is:

UPDATE tableName 
SET column1 = 'name',
    column2 = 'lastname',
    columnN =  valueN
WHERE ID = X

build the string thusly and it should work.

Sign up to request clarification or add additional context in comments.

Comments

1

That's the syntax for an INSERT - for an UPDATE it's

UPDATE Table SET Field1=Value1, Field2=Value2, etc WHERE ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.