Art-
Because the age changes over time, you should NOT store age group in your table.
You should calculate it in a query:
Age: DateDiff("yyyy", [DOB], Date()) + Int(Format(Date(), "mmdd") <
Format([DOB], "mmdd"))
AgeGroupID: Switch([Age] <= 18, 1, [Age] <= 21, 2, [Age] <= 25, 3, [Age] <= 30,
4, [Age] <= 35, 5, [Age] <= 40, 6, [Age] <= 49, 7, True, 8)
John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Art
Sent: Friday, July 15, 2011 6:12 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Updating table with Age Group entry
I have a table called tblStudent:
tblStudent
StudentID PK
LastName
FirstName
DOB
AgeGroupID - FK to tlkpAgeGroup
The tlkpAgeGroup table contains the following records:
AgeGroupID AgeGroupName
1 18 and Under
2 19 - 21
3 22 - 25
4 26 - 30
5 30 - 35
6 36 - 40
7 41 - 49
8 50 and over
What I am trying to do is update the AgeGroupID field in tblStudent with the
appropriate number based on the DOB. Any ideas?
Thanks,
Art Lorenzini,
Sioux Falls, SD
------------------------------------
Yahoo! Groups Links
Jumat, 15 Juli 2011
RE: [MS_AccessPros] Updating table with Age Group entry
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar