If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How do I calculate ages in a simple table in Access?
My table is simple. Field names are Last Name, First Name, Birthdate, Age. I
would like it to calculate the age when I enter the birthdate. |
#2
|
|||
|
|||
How do I calculate ages in a simple table in Access?
You don't. You can't store a moving target in a table.
The correct method is to calculate age (as of the current date) in your queries, forms, and reports. The proper formula is: DateDiff("yyyy",[Birthdate],Date())+(Format([Birthdate],"mmdd")Format(Date(),"mmdd")) For more details, read the previous posts on "calculated fields" or "calculating age". -- Rick B "Rodz" wrote in message ... My table is simple. Field names are Last Name, First Name, Birthdate, Age. I would like it to calculate the age when I enter the birthdate. |
#3
|
|||
|
|||
How do I calculate ages in a simple table in Access?
"Rodz" wrote in message
... My table is simple. Field names are Last Name, First Name, Birthdate, Age. I would like it to calculate the age when I enter the birthdate. You would calculate the age in a query at run-time. You would not usually store a calculation so your Age field is redundant. Look up "calculated fields" and "DateDiff" in the help - you'd need to find the difference between the system date (using the "Date() function") and the stored date and then express it in the format of your choice. You'd also need to handle nulls in the DOB field so you don't get run-time errors. Regards, Keith. www.keithwilby.com |
#4
|
|||
|
|||
How do I calculate ages in a simple table in Access?
As others have mentioned you USUALLY don't store the age. However, if you
need the age as of the date of entry, then you either need to store the date of entry (and use it to calculate the age when you need the age) or you do need to store the age. The only way that Access will populate a field with a calculation is through a form. Are you using a form for data entry? Normally, you should be. The formula for calculating age (in years) is DateDiff("yyyy", [Bdate], Date())+ Int( Format(Date(), "mmdd") Format( [Bdate], "mmdd") ) "Rodz" wrote in message ... My table is simple. Field names are Last Name, First Name, Birthdate, Age. I would like it to calculate the age when I enter the birthdate. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Query is not updatable - | Doug Johnson via AccessMonster.com | Running & Setting Up Queries | 3 | January 21st, 2006 12:36 AM |
Multiple Options Group | Patty Stoddard | Using Forms | 19 | August 4th, 2005 02:30 PM |
Many-to-many implementation problem | Al Williams | Database Design | 15 | April 29th, 2005 05:19 PM |
Manual line break spaces on TOC or Table of tables | Eric | Page Layout | 9 | October 29th, 2004 04:42 PM |
Table Wizard Does Not Set Relationship if Foreign Key and Primary Key Name Do Not Match Exactly in Case. | HDW | Database Design | 3 | October 16th, 2004 03:42 AM |