[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

updating more than 1 field using sql statement

Posted on 2002-07-20
7
Medium Priority
?
135 Views
Last Modified: 2010-05-02
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.
0
Comment
Question by:sjmmajor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 7166766
try this update statement example

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


hongjun
0
 
LVL 2

Expert Comment

by:yongyih
ID: 7166848
Syntax
UPDATE [DatabaseName1!]TableName1
SET Column_Name1 = eExpression1
  [, Column_Name2 = eExpression2 ...]
  WHERE FilterCondition1 [AND | OR FilterCondition2 ...]]


Good Luck.
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7168000
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:sjmmajor
ID: 7169335
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?
0
 
LVL 2

Accepted Solution

by:
priya_pbk earned 200 total points
ID: 7170111
This..

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

would be then..

*
sSql1 = "UPDATE 22shop_5min SET jobnumber= " & Text1 & ",jobname='" & Text2 & "',jobdesc='" & Text3 & "' where [22shop_5min].id = 1"

This is just an example. Basically what you are doing here is dynamically creating a sql-query at runtime. It's simple enough!!

*the jobName and jobdesc are dummy fields just to show how exactly it should be written.

Hope this helps!

-priya
0
 

Author Comment

by:sjmmajor
ID: 7170230
Thanks so much.  It was syntax that was getting me.  I knew it had to be easy.  I just couldn't see it.

Great!!
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7170965
you're welcome!
-priya
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question