View Single Post
  #3  
Old May 28th, 2006, 11:16 PM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default Writing and IIf statement in Access?

On Sun, 28 May 2006 11:20:01 -0700, Roger Drews wrote:

I am trying to write an IIf statement to use in a calculation where if PT1 is
zero it will use PC1 to determine the value. Here is the state I have tired
but I cannot get it to work. What am I doing wrong?
IIf([PT1]=0, [PC1]-[IC1], IIf([PT1]0,[PT1]-IC1])


Well, you've posted this calculation in a table design newsgroup, and
you cannot perform calculations in an Access table.

However, in a query you can ....
NewColumn:IIf([PT1]=0, [PC1]-[IC1], IIf([PT1]0,[PT1]-[IC1])

Or in a Form or Report (using an unbound text control ...
=IIf([PT1]=0, [PC1]-[IC1], IIf([PT1]0,[PT1]-[IC1])

Notice the [ bracket placed in front of the second IC1 field (which
you were missing in your expression).
Make sure the name of this control is not the same as the name of any
field used within it's control source expression.

What do you want to occur if the value of [PT1] is 0 ?


--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail