Storing information from calculeted fields

A

Arlindo Fragoso

Hi!
I'm a newbie and I've a simple question: I've a calculeted field (pupils
age) in a form and I want to store that value in a table. How to do this?
TIA
Arlindo Fragoso
 
G

Graham R Seach

Arlindo,

<<I want to store that value in a table>>
Don't. It is unwise to store calculated values. Since they can be calculated
at will (and in your case calculating an age is very easy), you are better
to do the calculation in a query or on a form/report, as needed.

The following code demonstrates how to calculate a peron's age:
intAge = Abs(DateDiff("yyyy", DOB, Date()) - IIf(Format(DOB, "mmdd") <=
Format(Date(), "mmdd"), 0, 1))

(Watch out for word-wrap. The above code should all be on one line).

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top