Tables

G

Guest

I want to calculate people's ages and add them into a table, I have the code:
Option Compare Database
Option Explicit

Public Function Age2(Birthdate As Date)

Age2 = Int((Date - Birthdate) / 365.25)

End Function

Is it possible to take this code and make it calculate and then add the
people's ages to the table?
 
J

Jeff Boyce

Consider the following scenario before you actually start adding "ages" to
your table...

You add a new person. That person's birthday is tomorrow.

You add another new person. That person's birthday is one month away.

If you don't go into your table and refresh the "age" value EVERY DAY, you
can count on it being out of synch with the DateOfBirth data perhaps as soon
as tomorrow!

This would be a situation in which it would make more sense to use a query
to calculate people's age when needed rather than trying to store "age" and
keep it up to date.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

You're right, thanks

Jeff Boyce said:
Consider the following scenario before you actually start adding "ages" to
your table...

You add a new person. That person's birthday is tomorrow.

You add another new person. That person's birthday is one month away.

If you don't go into your table and refresh the "age" value EVERY DAY, you
can count on it being out of synch with the DateOfBirth data perhaps as soon
as tomorrow!

This would be a situation in which it would make more sense to use a query
to calculate people's age when needed rather than trying to store "age" and
keep it up to date.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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