"PeterW" <pwooly@btinternet.comwrote in
news:09ednaurh7wFsH_ZnZ2dnUVZ8tKdnZ2d@bt.com:
Quote:
Hello,
>
I have a table that contains fields for WeekNumber,
OilReceived and OilRemaining.
>
WeekNum OilRecd OilRem
4 1200
5 1000 2000
6 1800
>
>
To calculate the oil used, I need to subtract this weeks oil
remaining from last weeks oil remaining and add this weeks oil
received.
>
Is there a way to reference the previous recordset value in a
query to allow me to achieve this.
>
I have done this by making a new table of oil usage using VB,
but would prefer to do it through a query.
>
Any help would be appreciated.
>
>
Easy. Create a query from design view.Put the table in the query
twice. From table properties, alias the first as ThisWeek, the
other as lastWeek.
Select each field from thisweek and weeknum, oilrem from
lastweek. In the lastweek.weeknum criteria row,
put [thisweek].[weeknum]-1. run the query and verify that things
line up the way you want.
You'll need to put a record for week 0 in the table, with 0 as
values
Put the criteria for thisWeek.weeknum as 0
Create a calculated field and save the completed query.
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from
http://www.teranews.com