IIf statement in the unbound box / calculated field / Subform

G

Guest

Hello and thank you for reading this thread

Is there a way to create a calculated field using IIf statement in the control source of an unbound box, on the Subform

I have the following in the ControlSource of an unbound box called: [5500ExtDue

=DateAdd("m",2,[5500 Due]+15

What I need is to add a condition that if field [5500Ext] is checked (also on the subform), then
DateAdd("m",2,[5500 Due]+15)
or if not, [5500ExtDue] should be blank

So, the [5500Ext] is on the subform, DataType: Yes/N
[5500 Due] and [5500ExtDue] are also fields of this subform. [5500 Due] brings you previosuly entered value, and [5500ExtDue] needs to be calculated under the above condition. Without the condition and with the current expression, I am calculating all [5500ExtDue fields], where I really need those only where [5500Ext] is checked: yes

Thank you for your help

Regards

Natali
 
M

Marshall Barton

Natalia said:
I have the following in the ControlSource of an unbound box called: [5500ExtDue]

=DateAdd("m",2,[5500 Due]+15)

What I need is to add a condition that if field [5500Ext] is checked (also on the subform), then
DateAdd("m",2,[5500 Due]+15)
or if not, [5500ExtDue] should be blank.

So, the [5500Ext] is on the subform, DataType: Yes/No
[5500 Due] and [5500ExtDue] are also fields of this subform. [5500 Due] brings you previosuly entered value, and [5500ExtDue] needs to be calculated under the above condition. Without the condition and with the current expression, I am calculating all [5500ExtDue fields], where I really need those only where [5500Ext] is checked: yes.


Try this:

=IIf([5500Ext], DateAdd("m",2,[5500 Due]+15), Null)
 
G

Guest

Thanks Marsh, this works
I somehow thought that for the IIf statement you have to say: IIf[5500Ext]="yes"....but I was wrong!
Again BIG Thanks
Regards

Natali
 
M

Marshall Barton

Natalia said:
Thanks Marsh, this works.
I somehow thought that for the IIf statement you have to say: IIf[5500Ext]="yes"....but I was wrong!!
Again BIG Thanks.


You might be able to get away with using IIf([5500Ext]=Yes
(without the quotes), if the environment you have the
expression in has Yes as a synonym of True. Technically, a
check box bound to a Yes/No field can only be True or False.
Since the IIf condition is converted to a True/False value
and the Yes/No field is already a True/False, you don't need
to compare it to anything.
 

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

Top