Solved

Access Query / Expression :total of multiple feilds

Posted on 2003-11-10
1
2,252 Views
Last Modified: 2008-02-01
This should be simple looking to sum up all of these route times but when i run the query the total feild is empty why and how do I fix it ????

here is the query>

SELECT route.RouteType, route.RouteName, route.UnitType, [route]![Shear]+[route]![Amada]+[route]![Brake]+[route]![Spot]+[route]![Router]+[route]![Buff]+[route]![Powder]+[route]![Weld]+[route]![Deburr]+[route]![ReShear]+[route]![Radius]+[route]![Insert]+[route]![Drill]+[route]![CutoffSaw]+[route]![Notcher]+[route]![StoneSaw]+[route]![Hinge Emboss] AS totaltime, route.Shear, route.Amada, route.Brake, route.Spot, route.Router, route.Buff, route.Powder, route.Weld, route.Deburr, route.ReShear, route.Radius, route.Insert, route.Drill, route.CutoffSaw, route.Notcher, route.StoneSaw, route.[Hinge Emboss], *
FROM route;
0
Comment
Question by:cmmonline
[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
1 Comment
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 100 total points
ID: 9717367
if ANY of the fields that are prt of the total is a NULL, then the Sum will result in a NULL value.

This looks like a very bad design, having all of those fields in the same record.

but since that is what you have, then you MUST account for the possible NULL values, using the NZ function:

SELECT route.RouteType, route.RouteName, route.UnitType, NZ([route]![Shear],0)+nz([route]![Amada],0)+nz([route]![Brake],0)+nz([route]![Spot],0)+nz([route]![Router],0)+nz([route]![Buff],0)+nz([route]![Powder],0)+nz([route]![Weld],0)+nz([route]![Deburr],0)+nz([route]![ReShear],0)+nz([route]![Radius],0)+nz([route]![Insert],0)+nz([route]![Drill],0)+nz([route]![CutoffSaw],0)+nz([route]![Notcher],0)+nz([route]![StoneSaw],0)+nz([route]![Hinge Emboss],0) AS totaltime, route.Shear, route.Amada, route.Brake, route.Spot, route.Router, route.Buff, route.Powder, route.Weld, route.Deburr, route.ReShear, route.Radius, route.Insert, route.Drill, route.CutoffSaw, route.Notcher, route.StoneSaw, route.[Hinge Emboss], *
FROM route;

a MUCH better and safer design would be to have a separate RouteTimes Table, :

RouteTime
------------------
RouteType
RouteStep
RouteTime

the Route Steps could then be either Strings like "ReShear", "Radius","Insert" etc, or else, if theses steps might change in the future, the have another table (Steps), and use the Primary key from that Table in the RouteTime Table.


The NZ function returns the value of the Field if it is NOT Null, and the value of the second argument (0 in the above) is the field IS NULL.

AW
0

Featured Post

Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

738 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