Group:  Microsoft Access ยป microsoft.public.access.gettingstarted
Thread: IIf statement and age

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

IIf statement and age
Philip Wright 31.07.2006 17:36:02
I'm wanting to calculate an age either by date of death or current date in a
query. How do I do this?

I currently have expressions to calculate current age, but if a patient is
deceased, I want it to display age at death instead of the current age.

Thanks.

Philip Wright
RE: IIf statement and age
Klatuu 31.07.2006 17:57:02
within your existing code,

IIf([DateOfDate] IS NULL, Date(), [DateOfDeath])

Just change DateOfDeath to the field name in your table that carries this
data.

"Philip Wright" wrote:

[Quoted Text]
> I'm wanting to calculate an age either by date of death or current date in a
> query. How do I do this?
>
> I currently have expressions to calculate current age, but if a patient is
> deceased, I want it to display age at death instead of the current age.
>
> Thanks.
>
> Philip Wright
Re: IIf statement and age
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> 31.07.2006 18:17:49
I don't think you can use IS NULL in the IIf statement. Try:

IIf(IsNull([DateOfDate]), Date(), [DateOfDeath])

Of course, this is exactly what the Nz function is for:

Nz([DateOfDate], Date())

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Klatuu" <Klatuu[ at ]discussions.microsoft.com> wrote in message
news:CDAF0314-B35D-4C13-AADE-1A92D25DAF4E[ at ]microsoft.com...
[Quoted Text]
> within your existing code,
>
> IIf([DateOfDate] IS NULL, Date(), [DateOfDeath])
>
> Just change DateOfDeath to the field name in your table that carries this
> data.
>
> "Philip Wright" wrote:
>
>> I'm wanting to calculate an age either by date of death or current date
>> in a
>> query. How do I do this?
>>
>> I currently have expressions to calculate current age, but if a patient
>> is
>> deceased, I want it to display age at death instead of the current age.
>>
>> Thanks.
>>
>> Philip Wright


Re: IIf statement and age
Klatuu 31.07.2006 18:25:02
In VBA you can't. In SQL you can.

"Douglas J. Steele" wrote:

[Quoted Text]
> I don't think you can use IS NULL in the IIf statement. Try:
>
> IIf(IsNull([DateOfDate]), Date(), [DateOfDeath])
>
> Of course, this is exactly what the Nz function is for:
>
> Nz([DateOfDate], Date())
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Klatuu" <Klatuu[ at ]discussions.microsoft.com> wrote in message
> news:CDAF0314-B35D-4C13-AADE-1A92D25DAF4E[ at ]microsoft.com...
> > within your existing code,
> >
> > IIf([DateOfDate] IS NULL, Date(), [DateOfDeath])
> >
> > Just change DateOfDeath to the field name in your table that carries this
> > data.
> >
> > "Philip Wright" wrote:
> >
> >> I'm wanting to calculate an age either by date of death or current date
> >> in a
> >> query. How do I do this?
> >>
> >> I currently have expressions to calculate current age, but if a patient
> >> is
> >> deceased, I want it to display age at death instead of the current age.
> >>
> >> Thanks.
> >>
> >> Philip Wright
>
>
>
Re: IIf statement and age
Philip Wright 31.07.2006 19:06:01
Thanks for the help. The Nz function worked as I wanted.

"Douglas J. Steele" wrote:

[Quoted Text]
> I don't think you can use IS NULL in the IIf statement. Try:
>
> IIf(IsNull([DateOfDate]), Date(), [DateOfDeath])
>
> Of course, this is exactly what the Nz function is for:
>
> Nz([DateOfDate], Date())
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Klatuu" <Klatuu[ at ]discussions.microsoft.com> wrote in message
> news:CDAF0314-B35D-4C13-AADE-1A92D25DAF4E[ at ]microsoft.com...
> > within your existing code,
> >
> > IIf([DateOfDate] IS NULL, Date(), [DateOfDeath])
> >
> > Just change DateOfDeath to the field name in your table that carries this
> > data.
> >
> > "Philip Wright" wrote:
> >
> >> I'm wanting to calculate an age either by date of death or current date
> >> in a
> >> query. How do I do this?
> >>
> >> I currently have expressions to calculate current age, but if a patient
> >> is
> >> deceased, I want it to display age at death instead of the current age.
> >>
> >> Thanks.
> >>
> >> Philip Wright
>
>
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net