Don't know the right expression

stef123

Registered User.
Local time
Today, 01:27
Joined
Sep 12, 2005
Messages
11
Hi there,
I can't seem to figure out how to add a new field in my report. I have an existing report about cities, it's population and the country which it is in.It's alphabetically ranked on the name of the cities. What I need to do now is add an extra field with the population of the country divided by the surface of the country. How to do this? Which expression do I have to use? The fields 'population' and 'surface' are both in a table called 'country'

Thanks
 
Merely add a textbox (from to toolbar) to your report, and then set it controlsource to

=[polulation]/[surface]

If surface is ever zero or null you'll of couse get an error, so you might want to use

=iif([surface] & "" ="" or nz([surface]) =0,"",=[polulation]/[surface])

I have found that using nz([surface]) does no act regularly with nulls.
 
I have found that using nz([surface]) does no act regularly with nulls.
you are confusing nulls with zero-length strings. That means that:
=iif([surface] & "" ="" or nz([surface]) =0,"",=[polulation]/[surface])
Should be the following because if surface is numeric, it CANNOT contain a ZLS:
=iif(nz([surface],0) =0,null,[polulation]/[surface])

Returning "" when the surface is null tells Jet that you want the expression to return a string. That could cause problems with any summary calculations.

I also removed the extraneous "=" in the false path of the IIf().
 
Wow guys, thanks for the respond, but you are way out of my league. I've tried just setting the controlsource to =[population]/[surface], also i've tried =iif(nz([surface],0) =0,null,[population]/[surface]). In both cases I'm asked to enter a parameter value. What do I need to do there?
 
That means that your report's recordsource has a criteria field (in the WHERE clause) which does not exist, possibly the field name is misspelled.
 

Users who are viewing this thread

Back
Top Bottom