Link to home
Start Free TrialLog in
Avatar of sjmmajor
sjmmajor

asked on

updating more than 1 field using sql statement

Here is the code I am now using.  How would I rewrite this to update more than 1 field without writing multiple Update statements?  I have around 30 fields to actually update in my Access Database.
Avatar of hongjun
hongjun
Flag of Singapore image

try this update statement example

update table_name
set field1 = field1_value,
field2 = field2_value
where id = 1


hongjun
Syntax
UPDATE [DatabaseName1!]TableName1
SET Column_Name1 = eExpression1
  [, Column_Name2 = eExpression2 ...]
  WHERE FilterCondition1 [AND | OR FilterCondition2 ...]]


Good Luck.
Avatar of priya_pbk
priya_pbk

I think you have forgotton to post your code, anyways hongjun and yongyih are correct for the update statement. How were you doing the same then??

-priya
Avatar of sjmmajor

ASKER

I tried the above and it gives me a parameter error.  Here is my code.

sSql1 = "UPDATE 22shop_5min SET jobnumber= " & JobNumber22 & " where [22shop_5min].id = 1"

If I had fields
text1
text2
text3
how would I go about using those fields in one statement?
ASKER CERTIFIED SOLUTION
Avatar of priya_pbk
priya_pbk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks so much.  It was syntax that was getting me.  I knew it had to be easy.  I just couldn't see it.

Great!!
you're welcome!
-priya