I'm relatively new to access, and am trying to accomplish something that I think is relatively simple but, in my efforts, has lead to nothing but errors. What I am trying to do: I have a form in which I input dates for an event and a date of birth; from those two dates, I would like to generate an age of the person at the time the event occurred. I have written code using the date diff function that allowed for calculation of the age, displayed in years and months (i.e., I would be displayed as of today as being 43 years and 4 months old). That works well; however, I would like for a third box to display the age in days, but I want it to do the calculation only if the age is less than two months--otherwise, I would like for the box to read "Not calculated". I have tried IIf, and have tried Switch, and I'm sure if I ventured into macros (eek) I could do it there. But I am looking for something like an IIf function that would say (in layman's terms) if the age in years is 0 and the age in months is less than two, then the age in days is x. My current IIf statment reads:
IIf ([AgeYears)=0) & IIf ([AgeMonths]=0),=DateDiff("d",[DOB],[EventDate]), "Not calculated"))
I'm sure I am making a syntax error, since I'm kind of making this up as I go along--but if someone out there could correct it for me, I would be grateful.
IIf ([AgeYears)=0) & IIf ([AgeMonths]=0),=DateDiff("d",[DOB],[EventDate]), "Not calculated"))
I'm sure I am making a syntax error, since I'm kind of making this up as I go along--but if someone out there could correct it for me, I would be grateful.