You could create a query along the lines of:
SELECT responseID, pptID, questionnaireID,
interviewDate,
DateDiff("yyyy", tblParticpants.DOB, tblResponses.interviewDate) -
IIf(Format(tblResponses.interviewDate, "mmdd") <
Format(tblParticipants.DOB,
"mmdd"), 1, 0) AS Age,
interviewLanguage, interviewerID, ...
FROM tblResponses INNER JOIN tblParticipants
ON tblResponses.pptID = tblParticipants.pptID
WHERE questionnaireID = 5
UNION
SELECT responseID, pptID, questionnaireID,
interviewDate,
Null,
interviewLanguage, interviewerID, ...
FROM tblResponses
WHERE questionnaireID <> 5
What this would do is give you an additional field Age that would only be
populated for Question 5.
You'd then be able to use that query anywhere you would otherwise have
used
tblResponses.
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
dee said:
Thanks for your response. I'm sorry, I thought I had provided enough
information.
I guess where I am having difficulty is referencing the Interview Date
field
in another table. I'll try to be more clear:
tblParticipants
pptID (autonumber PK)
First
Last
DOB
etc.
tblResponses
responseID (autonumber PK)
pptID (fk)
questionnaireID (fk) (there are several questionnaires)
interviewDate
interviewLanguage
interviewerID (fk)
etc.
I need to determine the Age of the participant as of the (tblResponses)
interviewDate of questionnaireID **5** only, putting the result in the
tblParticipants.
I realize that this is unusual, but for historical purposes only, plus
the
fact that the data will be exported to a statistical package that
requires
this field, it's really the only choice I have.
Thanks so much for your help - I hope I have provided enough detail.
--
Thanks!
Dee
:
You haven't really given us much to go on, but to calculate age at a
particular date in time, you'd use
DateDiff("yyyy", [DOB], [SpecificDate]) - _
IIf(Format([SpecificeDate], "mmdd") < Format([DOB], "mmdd"), 1, 0)
In general, you shouldn't store ages. I suppose that since this
particular
age will never change, it might be okay to store it instead of the
DOB.
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
I have a DOB field in table1 and an Age field in table1 as well.
In table2, I have a field that contains a date that respondents
answered
specific questionnaires.
For historical purposes, I would like to capture the age of the
person
at
the time one questionnaire in particular was answered in the Age
field
of
table1.
I'm not sure how to go about this, especially since I need the
questionnaire
date to be for a specific questionnaire, i.e. questionnaireID 05
specifically.
I have searched high and low and can't seem to find anything like
this.
Any
help would be greatly appreciated!