Nz and whole numbers

J

jlute

UNNtWt: IIf([UNNtWtConvgal],Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]))

This returns a value only if a UNNtWtConvgal is a whole number.

Does anybody see why this is? Have I done something wrong with Nz? I
simply want to calculate INGDenlbgal or FADenlbgal with UNNtWtConvgal
if it has a value.

Thanks in advance!!!
 
M

Michel Walsh

iif( ) need 3 arguments, you have only two.

The first argument of iif is a test. So, actually, UUNtWtConvgal is
implicitly converted to a Boolean (ie: false if zero; null if null; true
otherwise).

The second argument is the Nz( , ) function.


Nz(INGDehlbgal, FADenlbgal) * UNNtWtConvgal


would return :

INGDehlbgal * UNNtWtConvgal ' if INGDehlbgal is not null,
FADenlbgal * UNNtWtConvgal ' otherwise



Vanderghast, Access MVP
 
B

Bob Barrows [MVP]

UNNtWt: IIf([UNNtWtConvgal],Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]))

This returns a value only if a UNNtWtConvgal is a whole number.

Does anybody see why this is? Have I done something wrong with Nz? I
simply want to calculate INGDenlbgal or FADenlbgal with UNNtWtConvgal
if it has a value.
You are treating UNNtWtConvgal as if it were a boolean value (true or
false), which is not a good idea. Try

UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]))

You also should supply the <falsepart> argument to the iif method:

UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]),
0)
 
J

jlute

Thanks, Bob and Michel! I should've seen this but I was brain-locked.
I actually have one other argument and some rounding:

UNNtWt: IIf([UNNtWtConvlb]<>0,Round([UNNtWtConvlb],
4),IIf([UNNtWtConvgal]<>0,Round(Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]),4)))

I have two scenarios:
1. A record has either a UNNtWtConvlb or a UNNtWtConvgal but can never
have both.
2. If a record has UNNtWtConvlb then return it.
3. If a record has UNNtWtConvgal then multiply it by either
INGDenlbgal or FADenlbgal (can never have both).

Thanks so much for the boost!

UNNtWt: IIf([UNNtWtConvgal],Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]))
This returns a value only if a UNNtWtConvgal is a whole number.
Does anybody see why this is? Have I done something wrong with Nz? I
simply want to calculate INGDenlbgal or FADenlbgal with UNNtWtConvgal
if it has a value.

You are treating UNNtWtConvgal as if it were a boolean value (true or
false), which is not a good idea. Try

UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]))

You also should supply the <falsepart> argument to the iif method:

UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]),
0)

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
M

Michel Walsh

Then, it seems the following should work:

Nz(UNNtWtConvlb , UNNtWtConvgal * Nz(INGDenlbgal , FADenlbgal ))


Vanderghast, Access MVP



Thanks, Bob and Michel! I should've seen this but I was brain-locked.
I actually have one other argument and some rounding:

UNNtWt: IIf([UNNtWtConvlb]<>0,Round([UNNtWtConvlb],
4),IIf([UNNtWtConvgal]<>0,Round(Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]),4)))

I have two scenarios:
1. A record has either a UNNtWtConvlb or a UNNtWtConvgal but can never
have both.
2. If a record has UNNtWtConvlb then return it.
3. If a record has UNNtWtConvgal then multiply it by either
INGDenlbgal or FADenlbgal (can never have both).

Thanks so much for the boost!

UNNtWt: IIf([UNNtWtConvgal],Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]))
This returns a value only if a UNNtWtConvgal is a whole number.
Does anybody see why this is? Have I done something wrong with Nz? I
simply want to calculate INGDenlbgal or FADenlbgal with UNNtWtConvgal
if it has a value.

You are treating UNNtWtConvgal as if it were a boolean value (true or
false), which is not a good idea. Try

UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]))

You also should supply the <falsepart> argument to the iif method:

UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]),
0)

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
J

jlute

Oh, sure. Easy for you to say when you have the syntax skills of
God! :)

Geez - that's rather simple. How the heck can I round it to 4? I tried
every which way but couldn't get it.

Then, it seems the following should work:

Nz(UNNtWtConvlb , UNNtWtConvgal * Nz(INGDenlbgal , FADenlbgal ))

Vanderghast, Access MVP


Thanks, Bob and Michel! I should've seen this but I was brain-locked.
I actually have one other argument and some rounding:

UNNtWt: IIf([UNNtWtConvlb]<>0,Round([UNNtWtConvlb],
4),IIf([UNNtWtConvgal]<>0,Round(Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]),4)))

I have two scenarios:
1. A record has either a UNNtWtConvlb or a UNNtWtConvgal but can never
have both.
2. If a record has UNNtWtConvlb then return it.
3. If a record has UNNtWtConvgal then multiply it by either
INGDenlbgal or FADenlbgal (can never have both).

Thanks so much for the boost!

UNNtWt: IIf([UNNtWtConvgal],Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]))
This returns a value only if a UNNtWtConvgal is a whole number.
Does anybody see why this is? Have I done something wrong with Nz? I
simply want to calculate INGDenlbgal or FADenlbgal with UNNtWtConvgal
if it has a value.
You are treating UNNtWtConvgal as if it were a boolean value (true or
false), which is not a good idea. Try
UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]))
You also should supply the <falsepart> argument to the iif method:
UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]),
0)
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.- Hide quoted text -

- Show quoted text -
 
M

Michel Walsh

Four digits after the point?


Int(0.5 + x / CDec(0.0001) ) * CDec(0.0001)

will round x, positive, to 4 digits. Replace .0001 by 0.01 for two digits,
or by .25 to round to the quarter (.00, .25, .50, .75), and so on...

So, alias your previous expression to, say, x, and, in a new column, compute
the previous expression. To give an alias (a name) to a computed expression,
use:

aliasName : expression



Vanderghast, Access MVP

Oh, sure. Easy for you to say when you have the syntax skills of
God! :)

Geez - that's rather simple. How the heck can I round it to 4? I tried
every which way but couldn't get it.

Then, it seems the following should work:

Nz(UNNtWtConvlb , UNNtWtConvgal * Nz(INGDenlbgal , FADenlbgal ))

Vanderghast, Access MVP


Thanks, Bob and Michel! I should've seen this but I was brain-locked.
I actually have one other argument and some rounding:

UNNtWt: IIf([UNNtWtConvlb]<>0,Round([UNNtWtConvlb],
4),IIf([UNNtWtConvgal]<>0,Round(Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]),4)))

I have two scenarios:
1. A record has either a UNNtWtConvlb or a UNNtWtConvgal but can never
have both.
2. If a record has UNNtWtConvlb then return it.
3. If a record has UNNtWtConvgal then multiply it by either
INGDenlbgal or FADenlbgal (can never have both).

Thanks so much for the boost!

UNNtWt: IIf([UNNtWtConvgal],Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]))
This returns a value only if a UNNtWtConvgal is a whole number.
Does anybody see why this is? Have I done something wrong with Nz? I
simply want to calculate INGDenlbgal or FADenlbgal with UNNtWtConvgal
if it has a value.
You are treating UNNtWtConvgal as if it were a boolean value (true or
false), which is not a good idea. Try
UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]))
You also should supply the <falsepart> argument to the iif method:
UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]),
0)
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.- Hide quoted text -

- Show quoted text -
 
J

jlute

Slick! Thanks, Michel!

Four digits after the point?

Int(0.5 + x / CDec(0.0001)  ) * CDec(0.0001)

will round x, positive, to 4 digits. Replace .0001 by 0.01 for two digits,
or by .25  to round to the quarter (.00, .25, .50, .75), and so on...

So, alias your previous expression to, say, x, and, in a new column, compute
the previous expression. To give an alias (a name) to a computed expression,
use:

    aliasName :  expression

Vanderghast, Access MVP


Oh, sure. Easy for you to say when you have the syntax skills of
God! :)

Geez - that's rather simple. How the heck can I round it to 4? I tried
every which way but couldn't get it.

Then, it seems the following should work:
Nz(UNNtWtConvlb , UNNtWtConvgal * Nz(INGDenlbgal , FADenlbgal ))
Vanderghast, Access MVP
Thanks, Bob and Michel! I should've seen this but I was brain-locked.
I actually have one other argument and some rounding:
UNNtWt: IIf([UNNtWtConvlb]<>0,Round([UNNtWtConvlb],
4),IIf([UNNtWtConvgal]<>0,Round(Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]),4)))
I have two scenarios:
1. A record has either a UNNtWtConvlb or a UNNtWtConvgal but can never
have both.
2. If a record has UNNtWtConvlb then return it.
3. If a record has UNNtWtConvgal then multiply it by either
INGDenlbgal or FADenlbgal (can never have both).
Thanks so much for the boost!
On Aug 5, 9:07 am, "Bob Barrows [MVP]" <[email protected]>
wrote:
(e-mail address removed) wrote:
UNNtWt: IIf([UNNtWtConvgal],Nz([INGDenlbgal],
[FADenlbgal]*[UNNtWtConvgal]))
This returns a value only if a UNNtWtConvgal is a whole number.
Does anybody see why this is? Have I done something wrong with Nz? I
simply want to calculate INGDenlbgal or FADenlbgal with UNNtWtConvgal
if it has a value.
You are treating UNNtWtConvgal as if it were a boolean value (true or
false), which is not a good idea. Try
UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]))
You also should supply the <falsepart> argument to the iif method:
UNNtWt: IIf([UNNtWtConvgal] <> 0,
Nz([INGDenlbgal],[FADenlbgal]*[UNNtWtConvgal]),
0)
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
 

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

Similar Threads


Top