Solved

Access Update query syntax

Posted on 2014-04-02
5
370 Views
Last Modified: 2014-04-03
Good Afternoon Guru's,

I am having an issue with an update query in ms access.

table structure:
                                         month1  month2   month3   month4  etc.......
grp1   money                        5.00       6.23        52.3         54.21
grp1   something
grp1   something1
grp1   average
grp2   money                        5.36        8.21        4.14          5.98
grp2   something
grp2   something1
grp2   average

Issue: We need to update each grp's 'average' line for each month based on the sum of all values in each respective grps 'money' line.
This is what is created so far, and I am running into syntax issues:

UPDATE ChartDBSource_Template
SET ChartDBSource_Template.Mar = ([ChartDBSource_Budget].[Mar] + [ChartDBSource_Budget].[Jan] + ([ChartDBSource_Budget].[Feb] + ([ChartDBSource_Budget].[Mar] + ([ChartDBSource_Budget].[Apr] + ([ChartDBSource_Budget].[May] + ([ChartDBSource_Budget].[Jun] + ([ChartDBSource_Budget].[Jul] + ([ChartDBSource_Budget].[Aug] + ([ChartDBSource_Budget].[Sep] + ([ChartDBSource_Budget].[Oct] + ([ChartDBSource_Budget].[Nov] + ([ChartDBSource_Budget].[Dec] / 12)
WHERE ChartDBSource_Template.CHART_BIN like 'BudAvg';
0
Comment
Question by:UserName935
[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
  • 2
  • 2
5 Comments
 
LVL 38

Accepted Solution

by:
Jim P. earned 500 total points
ID: 39973062
Your parentheses were off. The Nz is a IfNull function. Try this:

UPDATE ChartDBSource_Template
SET ChartDBSource_Template.Mar = ((Nz([ChartDBSource_Budget].[Mar],0) +
                                  Nz([ChartDBSource_Budget].[Jan],0) +
                                  Nz([ChartDBSource_Budget].[Feb],0) +
                                  Nz([ChartDBSource_Budget].[Mar],0) +
                                  Nz([ChartDBSource_Budget].[Apr],0) +
                                  Nz([ChartDBSource_Budget].[May],0) +
                                  Nz([ChartDBSource_Budget].[Jun],0) +
                                  Nz([ChartDBSource_Budget].[Jul],0) +
                                  Nz([ChartDBSource_Budget].[Aug],0) +
                                  Nz([ChartDBSource_Budget].[Sep],0) +
                                  Nz([ChartDBSource_Budget].[Oct],0) +
                                  Nz([ChartDBSource_Budget].[Nov],0) +
                                  Nz([ChartDBSource_Budget].[Dec],0) )/ 12)
WHERE ChartDBSource_Template.CHART_BIN like 'BudAvg';

Open in new window

0
 

Author Closing Comment

by:UserName935
ID: 39973363
Thank you very much !!!!
0
 
LVL 38

Expert Comment

by:Jim P.
ID: 39973409
UserName935,

Thank you for accepting my answer. For future reference you may want to look at the grading standards for EE.
0
 

Author Comment

by:UserName935
ID: 39974958
I apologize if I failed on the grading task.  

If it is possible, feel free to change it to what it is you desire, and, thank you again for the assistance.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 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