Transfering a formula from a form into a table

Paul8267

New member
Local time
Today, 18:38
Joined
Nov 14, 2007
Messages
1
I've built a table and used it to build a form. One the form I have three boxes, one to enter the DoB, and two others that record the age and also put the individual into an age bracket.

In the latter two categories I have entered a formula in the Properties Box under Data & Control Source (the formulas are below) to automatically work out what the age and age bracket is when the DoB is entered. This works fine but the information isn't transferred back to the table.

Do I need to do the info in the table first and then update the form? And if so where do I enter the info in the field properties in the table design view?

=Int((Date()-[DOB])/365.25)

=IIf([age]>=50,"50+",IIf([age]>=35,"35-49",IIf([age]>=25,"25-34","16-24")))

Many thanks in advance
 
Why would you store the age? If you do you store age you'll have to update your table tomorrow to make sure the right age is stored for every entry.

Values that can be calculated from info stored in the DB should not be stored but calculated when needed.
 
Never store a persons age, as it will be out of date the next day. Here is an age function

for Access only as it uses the fact that true is -1 and false is 0

Public Function CalcAge(DOB as Variant) As Integer
Dim CompareDate As Date
CompareDate = Date
If Not IsNull(DOB) Then
CalcAge = Year(CompareDate) - Year(DOB) + (DateSerial(Year(CompareDate), Month(DOB), Day(DOB)) > CompareDate)
End If
End Function
 

Users who are viewing this thread

Back
Top Bottom