[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Calculate Sum of a field in a table using access query

Posted on 2009-02-12
5
Medium Priority
?
872 Views
Last Modified: 2012-05-06
I would like to add a field to my existing query that would perform a sum calculation off of a field in the table that is shown in the query.  THis field is a cumulative amount that is not in any table.  For example; I know the Machine Num and would like to calculate the cumulated Operating hours.  Table has MachNum and OpHrs.  I am passing the MachNum from another form so I know that coming in.
0
Comment
Question by:avalonwgi
  • 3
5 Comments
 
LVL 26

Accepted Solution

by:
tigin44 earned 2000 total points
ID: 23626166
something like this may help you...

SELECT MachineNum, SUM(OpHrs)
FROM yourTable
WHERE MachineNum = @MachineNum
GROUP BY MachineNum
0
 
LVL 75
ID: 23626270
try this:

SELECT Table1.FIELD1, Sum(Table1.FIELD2) AS OpHrs
FROM Table1
WHERE (((Table1.FIELD1)=[Forms].[YourFormName].[txtMachNum]))
GROUP BY Table1.FIELD1;

Where FIELD1 is MachNum , FIELD2 = OpHrs

0
 
LVL 75
ID: 23626285
I'm using  txtMachNum as the Name of the control on your form passing the MachNum

mx
0
 

Author Closing Comment

by:avalonwgi
ID: 31546282
It looks like it is working.  I still have more to do to fully test but thanks for your help.
0
 
LVL 75
ID: 23626702
How will this work in an Access database:

@MachineNum

?

Also, the Accepted solution does not take into account

"I am passing the MachNum from another form so I know that coming in."

??
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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

834 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