Paulo-

You can use DSum to calculate the rolling forward value as long as previous
rows have a unique key.  In your first example, it might look like:

  RollingSum: DSum("[Production]", "MyTable", "Machine = " & [Machine] & "
AND Year < " & [Year])

The bank account problem is more difficult because you show multiple entries
on a given date.  You need some sort of unique sequence number to do the
less than test.

John Viescas, author
"Building Microsoft Access Applications"
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/

> -----Original Message-----
> From: Paulo Ferreira [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, March 22, 2005 10:12 AM
> To: ms_access@yahoogroups.com
> Subject: [ms_access] Sum of values
> 
> 
> 
> Hello;
> 
> I'm new to this group and I need help with a problem that 
> happens to me a lot and still don't have a solution.
> 
> I need to have a column in a query that sums or acumulates 
> values of the previous records. For example a machine (M001) 
> works 1000 hours in 2001. The acumulate value is 1000, the 
> same machine works 1600 in 2002, te acumulated value turns to 
> 2600 is this same record.
> 
> Example:
> 
>       Machine Year  Year Production Sum   
>       100 2001 14.567,00 21.227,00   
>       100 2002 16.388,00 37.615,00   
>       100 2003 16.169,00 53.784,00   
>       200 2001 6.660,00 6.660,00   
>       200 2002 6.972,00 13.632,00   
>       200 2003 5.934,00 19.566,00   
>           
>           
>           
>       If it a bank acount (don't know if it is the same technic 
>           
>       Account Date Kind of movement Debit Credit Value 
>       111 01-Jan deposit  500 500 
>       111 02-Jan deposit  100 600 
>       111 03-Jan payment 50  550 
>       111 04-Jan payment 10  540 
>       130 01-Jan deposit  2 2 
>       130 01-Jan deposit  1 3 
>       130 02-Jan deposit  1 4 
>       130 03-Jan payment 1  3 
>       130 04-Jan payment 1  2 
>       130 01-Jan deposit  3 5 
> 
> 
> 
> Hope earing from you
> 
> Thanks
> Paulo Ferreira
> 
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ms_access/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to