Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / September 2006

Tip: Looking for answers? Try searching our database.

Running Totals

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
StuJol - 10 Sep 2006 22:16 GMT
i have an Access 2003 qry "qryP11"

Payment ID      Employee ID       Week Number      Pay        Pay to date
     1                      4                         1               100  
          100
     2                      4                         2               100  
          200
     3                      4                         3               250  
          450

im trying to work out the correct expression to give me the pay to date
values, a running sum. Can someone point me in the right direction please.
Wayne-I-M - 10 Sep 2006 22:33 GMT
Hi

It may be a better idea to create a report from the query and then use a
running sum in a unbound box to produce the desired result.

Hope this helps

Signature

Wayne
Manchester, England.
Enjoy whatever it is you do

> i have an Access 2003 qry "qryP11"
>
[quoted text clipped - 8 lines]
> im trying to work out the correct expression to give me the pay to date
> values, a running sum. Can someone point me in the right direction please.
StuJol - 10 Sep 2006 23:05 GMT
thanks for the reply but im not using a report, just  qry

> Hi
>
[quoted text clipped - 15 lines]
> > im trying to work out the correct expression to give me the pay to date
> > values, a running sum. Can someone point me in the right direction please.
Wayne-I-M - 10 Sep 2006 23:09 GMT
No worries you can create a standard module and refer to this is the query.

Check out this link for details

http://support.microsoft.com/?kbid=205183

Good luck
Signature

Wayne
Manchester, England.
Enjoy whatever it is you do

> thanks for the reply but im not using a report, just  qry
>
[quoted text clipped - 17 lines]
> > > im trying to work out the correct expression to give me the pay to date
> > > values, a running sum. Can someone point me in the right direction please.
Neil Sunderland - 10 Sep 2006 23:18 GMT
>im trying to work out the correct expression to give me the pay to date
>values, a running sum. Can someone point me in the right direction please.

You need to join the table to itself, and get the total pay for each
employee for all the weeks that is less than or equal to the current
record.

SELECT
   A.Payment_ID, A.Employee_ID, A.Week_Number, A.Pay,
  (SELECT
      Sum(B.Pay)
   FROM
      Payments AS B
   WHERE
       A.Employee_ID = B.Employee_ID AND
       A.Week_Number >= B.Week_Number) AS Pay_To_Date
FROM
   Payments AS A

Please note that I've assumed the table you're pulling the data from
is called 'Payments', and I've also changed all the spaces in your
field names to underscores, as I don't like typing all those square
brackets :)

Signature

Neil Sunderland
Braunton, Devon

Please observe the Reply-To address

Marshall Barton - 11 Sep 2006 00:06 GMT
>i have an Access 2003 qry "qryP11"
>
[quoted text clipped - 8 lines]
>im trying to work out the correct expression to give me the pay to date
>values, a running sum.

Use a subquery:

SELECT T.[Payment ID], T.[Employee ID],
                T.[Week Number], T.Pay,
                (SELECT Sum(X.Pay)
                FROM table As X
                WHERE X.[Employee ID] = T.[Employee ID]
                    And X.[Week Number] <= T.[Week Number]
                ) As [Pay to Date]
FROM table As T
Signature

Marsh
MVP [MS Access]

Michel Walsh - 14 Sep 2006 22:55 GMT
Hi,

You already got answers with a subquery, I would personally use a join:

SELECT LAST(T.[Payment ID]), T.[Employee ID], T.[Week Number], LAST(T.Pay),
SUM(X.Pay)
FROM table AS t INNER JOIN table AS x
   ON X.[Employee ID] = T.[Employee ID]  And X.[Week Number] <= T.[Week
Number]
GROUP BY T.[Employee ID], T.[Week Number]

Hoping it may help,
Vanderghast, Access MVP

>i have an Access 2003 qry "qryP11"
>
[quoted text clipped - 8 lines]
> im trying to work out the correct expression to give me the pay to date
> values, a running sum. Can someone point me in the right direction please.
StuJol - 27 Sep 2006 21:59 GMT
i've found the solution, it is

' Find the record that matches the control.
   Dim rs As Object

   Set rs = Form_sbfrmEmployees.sbfrmEmployeesDetails.Form.RecordsetClone
   rs.FindFirst "[Employee ID] = " & Str(Nz(Me![EmployeeID], 0))
   If Not rs.EOF Then
Form_sbfrmEmployees.sbfrmEmployeesDetails.Form.Bookmark = rs.Bookmark
   

> i have an Access 2003 qry "qryP11"
>
[quoted text clipped - 8 lines]
> im trying to work out the correct expression to give me the pay to date
> values, a running sum. Can someone point me in the right direction please.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.