Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Previous Values

Status
Not open for further replies.

Gregro

Vendor
Jul 6, 2003
3
ZA
In Excel one can do the following:

E7 = D6 + D7 ie add the previous record in a column to the current record in
the same column and get the total.

I have a database with data sorted by date. I want to be able to add one of
the other columns data using the previous months data plus the current
month. This sequence will be repeated every month.

Any ideas and assistance will be greatly appreciated.
 
Outline on how you might do with a simple example, Table1.

You can use an ID in your table (an autonumber field):

Table1 is:

ID Field1
1 10
2 2
3 4
4 1
5 8

You can create a query that does this:

SELECT [ID]+1 AS Expr1, Table1.Field1
FROM Table1;


You can then create a join between your table ID and the query ID (which is +1):

SELECT [Table1]![Field1]+[Query1]![Field1] AS Expr2
FROM Table1 INNER JOIN Query1 ON Table1.ID = Query1.Expr1;

which when you run gives you:

Expr2
12
6
5
9

Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top