How to use If() in Report

S

sg

Hi,

In Report design view, detail section, I like to come up % with the
following two fields
field1: $Last Year
field2: $This Year

$This Year/$Last Year

If $Last Year is 0 or null, I want it to be nothing, otherwise $ this
year/$Last Year.

How can I do this?
Any idea would be greatly appreciated.

Sarah
 
F

fredg

Hi,

In Report design view, detail section, I like to come up % with the
following two fields
field1: $Last Year
field2: $This Year

$This Year/$Last Year

If $Last Year is 0 or null, I want it to be nothing, otherwise $ this
year/$Last Year.

How can I do this?
Any idea would be greatly appreciated.

Sarah

In an unbound control:
=IIf(IsNull([$LastYear]) or [LastYear]=0,0,[$ThisYear]/[$LastYear])
 
J

JL

Hi sg,
I thought this is Form Coding not Reports. :)
The idea is the same. In Text Box field that calculate "$This Year/$Last
Year". In the control source "=iif(nz([$Last Year]) = 0, Null, [$This
Year]/[$Last Year])

Hope this helps.
 
S

sg

Thanks Fred and JL, this is just what I need and it works. I will do the
same in one of my form too.

Thanks again,
Sarah
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top