Here 'tis Karl...
SELECT T_Main.ID, T_Main.[Tag ID], T_Main.[Date of Birth], T_Main.Sex,
DateDiff("m",[Date Of Birth],Date()) AS AgeinMonths, IIf([AgeinMonths]
Between [LowAge] And [HighAge],[LifeStage],"Error") AS Stage
FROM T_Main, [T_Life Stage];
lexy
:
Open your query in design view, click on SQL icon, highlight all, copy, and
paste in a post.
I'll lok at it.
:
I've done that Karl but am getting odd results.
I've got the Life Stage Iif statement and the Age in Months statement in two
columns in the query, along with data from the base Table, but it's returning
lots of results instead of a result for each record i.e. 2. Each record is
appearing lots of times with varying results and lots of errors.
I'm bound to be doing something simple wrong as I'm not as familiar with 07
as with 03....
Any suggestions you can think of? Shame I can't do you a print screen.
Lexy
:
Open your query in design view and add the look-up table above the grid.
Then in a blank position of the Field row insert the calculated field I
posted.
Stage: IIF([Age] Between [LowAge] and [HighAge], [AgeStage], "Error")
:
Thanks Karl
Being thick here. I understand the need for a look-up table for the
differing Life Stages but I'm not sure where to use it.
I'm assuming that the Iif statement is used in expression builder in the
field for Life Stage on my form, but can you explain what I'm putting into
the query please and how the field/query know to refer to the table?
Thanks.
:
Create a translation table with three fields --
AgeStage LowAge HighAge
A 1 4.99999
B 5 9.99999
C 10 19.99999
etc
Stage: IIF([Age] Between [LowAge] and [HighAge], [AgeStage], "Error")
:
Hi
My query calculates the age in years and also years and months (2 separate
fields) based on a Date of Birth that's input by the user into the base Table.
I'd like a new field in the query to then automatically reflect the life
stage (there are 7 different life stages) based on what the current age is.
Can you advise how I might do this please?