conditional calculated field

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

Guest

How do I perform this conditional calculated field in a query or form

if disposition = "booked" then tot=price*quan

I want all the records displayed even if disposition<> "booked".

I tried IIF [disposition = "booked"],price*quan. I got #name
Thanks for the help.
 
******** said:
How do I perform this conditional calculated field in a query or form

if disposition = "booked" then tot=price*quan

I want all the records displayed even if disposition<> "booked".

I tried IIF [disposition = "booked"],price*quan. I got #name
Thanks for the help.

In addition to correcting your syntax for calling IIf(), you have to
decide what you want to appear in the field if disposition<> "booked".
Let's suppose that you want 0 to show in that case. Then you could use
the following expression in the controlsource of a textbox:

=IIf([disposition]="booked", [price]*[quan], 0)

Or you could define it as a calculated field in the form's recordsource
query:

tot: IIf([disposition]="booked", [price]*[quan], 0)
 
Back
Top