p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access (http://p2p.wrox.com/forumdisplay.php?f=18)
-   -   Storing Calculated Fields (http://p2p.wrox.com/showthread.php?t=17598)

dearnne August 30th, 2004 12:28 AM

Storing Calculated Fields
 
I have a calculated field called Saving which I want to store in the table. I know this isn't advisable, but I need to refer back to it constantly and want to know what the savings are when the information was entered. Does anyone know a way to do this?



jemacc August 30th, 2004 07:31 AM

Suggestion:

Avoid storing calculated fields. Create a table that stores this information and create a query and do your calculation there.

Take a look at the northwind access database that comes with MS Access

[u]Tables</u>
Order
Order Details

This will give you and idea on how to best approach your situation.



SerranoG August 30th, 2004 04:02 PM

Jemacc's advice is generally very true, but be careful to listen to what is asked. For example, Dearnne says, "...want to know what the savings are when the information was entered."

That raises a flag. Are you saying, Dearnne, that savings is dependent on WHEN it was entered and you need to save the number for historical reasons?

For example: exchange rates. Values based on those can be calculated; however, because exchange rates change daily, you WOULD have to store the actual exchange rate if you want to know what the value of something was from another country on a certain date.

In that case, Dearnne, you don't store the calculated value (listening Jemacc's good advice); you store the multiplier for that date, i.e. the exchange rate itself. Then if you want to know the value of something later, you THEN recalculate using the stored exchange rate.

So my question to you is, are you multiplying two numbers where the second number changes daily? If so, store the second number and its date, not the calculation of the two numbers. As jemacc says, you can recalculate anytime as long as you get the correct two numbers.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division

stoneman September 2nd, 2004 05:30 PM

Greg, Isee your point and I agree. If I am keeping my checking account history and I want to keep a running balance. How would I apply your suggestion in order to get a balance on a particular day when I am depositing and also taking money out?


All times are GMT -4. The time now is 03:52 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.