If Statements in and Expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

So I have a calculated field in an query that looks like this:

Product Thickness: [Depth To Water]-[Depth To Product]

If the value of that calculation is a null value (if [Depth to Product]
contains a null value) I want the field to be 0.0, can I write an if
statement in the expression? Or do I need to do it somewhere in VBA?

Thanks for the help gang!
 
Hi Larry,

Use the Nz function to convert any nulls to zero:

Product Thickness: Nz([Depth To Water],0) - Nz([Depth To Product],0)


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

So I have a calculated field in an query that looks like this:

Product Thickness: [Depth To Water]-[Depth To Product]

If the value of that calculation is a null value (if [Depth to Product]
contains a null value) I want the field to be 0.0, can I write an if
statement in the expression? Or do I need to do it somewhere in VBA?

Thanks for the help gang!
 
Yes,

example of expression:

iif(test criteria,yes part,no part)

you do use two i's.

example:

iif(1>0,"true","false")

result:
true

iif(1<0,"true","false")

result
false
 
Yes I agree with Tom. In fact this is preferred for what you are trying to do.
 
Hi Larry,

There's no reason that the Nz function shouldn't have worked for you....


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

This one didn't work for me, the IIf did work tho.

Thanks!!!!
__________________________________________

:

Hi Larry,

Use the Nz function to convert any nulls to zero:

Product Thickness: Nz([Depth To Water],0) - Nz([Depth To Product],0)


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

So I have a calculated field in an query that looks like this:

Product Thickness: [Depth To Water]-[Depth To Product]

If the value of that calculation is a null value (if [Depth to Product]
contains a null value) I want the field to be 0.0, can I write an if
statement in the expression? Or do I need to do it somewhere in VBA?

Thanks for the help gang!
 

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

Back
Top