Solved

Access Query / Expression :total of multiple feilds

Posted on 2003-11-10
1
2,263 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

630 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