View Single Post
  #4  
Old May 28th, 2004, 04:04 PM
fredg
external usenet poster
 
Posts: n/a
Default storing calulations

On Fri, 28 May 2004 22:34:49 +1000, DubboPete wrote:

Rick, on a tangent - almost!,
I can sympathise on why Steve wants to do something like this, and I am
interested to see if it can be done.

Each month I have to tally up the mileage and fuel purchased for a
substantial fleet of vehicles, and have to do it from hand-written sheets.
At the moment I use Access to calculate the start and end mileage difference
(naturally), and then have to use Calc.exe to total the number of litres
used for those miles/kilometres (which can be many entries). This means
'alt-tabbing' between Calc and Access. If the ability to use the Calc.exe
was available, or something similar on the same screen, it would certainly
make my life a lot easier!

Perhaps you can suggest some code to add up the multiple fuel purchases and
place it in the 'fuel_used' field?

TIA

DubboPete

"Rick Brandt" wrote in message
...
"Steve Fama" wrote in message
...
How do I store calulations in a table. I have calc. in a
form, how do I store the results in a table. Please help


In almost all cases you DON'T. If they can be calculated they don't need

to be
stored and it is bad design to do so. Can you explain why you want to?


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com



The reason for not storing calculated data is quite straight forward.
Data is sometimes incorrectly entered.
Correcting the incorrect data entry will leave the erroneous
previously calculated result.
If you can compute the calculation from already stored data, there is
no need to store the result. Re-compute it whenever needed.
Storing the result of a calculation wastes memory and storage space.

There are exceptions, of course, such as storing invoice data where
the cost of items on a particular date may have since been changed.

Here is one method to compute mileage driven using a query.

SELECT tblMultiCars.Auto, tblMultiCars.dteDate, tblMultiCars.Odometer,
Abs([Odometer]-DLookUp("Nz([Odometer])","tblMultiCars","[Auto] = '" &
[Auto] & "' and Month([dteDate]) = " & Month([dteDate])+1)) AS
MilesTraveled
FROM tblMultiCars
ORDER BY tblMultiCars.Auto, tblMultiCars.dtedate;


The Auto field holds the vehicle name, dteDate is the date driven, and
Odometer is the odometer reading on the dteDate.

Auto dtedate Odometer MilesTraveled
Caddy 01/01/2002 5000 1000
Caddy 02/01/2002 6000 500
Caddy 03/01/2002 6500
Ford 01/01/2002 3000 750
Ford 02/01/2002 3750 250
Ford 03/01/2002 4000
VW 01/01/2002 1000 450
VW 02/01/2002 1450 550
VW 03/01/2002 2000

You would use vehicle ID numbers, to differentiate the vehicles, but
this would give you a start.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.