IIf statement on form

L

Linkerbink

I have a form and two subforms. I want a field on the
form to display a result if one field on the lowest level
subform is null AND another field on that same subform is
not null. I tried the following, but to no avail...I
guess I'm missing something basic (I'm fairly new at
Access):

=IIf(IsNull([Forms]![Subform1]![Subform2]![Field1]) And
Not IsNull([Forms]![Subform1]![Subform2]!
[Field2]),"Result1","Result2")

Any help out there?
 
D

Dan Seibert

I would just use something like

=IIf(IsNull([Forms]![Subform1]![Subform2]![field1], "Result1", "Result2)

The problem is when you try to do this off a subform. There is a way to
do it but I haven't figured out how. When I had to do something like
this, I just made a hidden field on the main form (the one with the if
statement) that was set to the value of the subforms field. Then have
the if statement base off the hidden field. It made it a lot easier
than the info I found about doing this off a subform.
 
L

Linkerbink

Thanks...I'll try that.
-----Original Message-----
I would just use something like

=IIf(IsNull([Forms]![Subform1]![Subform2]! [field1], "Result1", "Result2)

The problem is when you try to do this off a subform. There is a way to
do it but I haven't figured out how. When I had to do something like
this, I just made a hidden field on the main form (the one with the if
statement) that was set to the value of the subforms field. Then have
the if statement base off the hidden field. It made it a lot easier
than the info I found about doing this off a subform.
I have a form and two subforms. I want a field on the
form to display a result if one field on the lowest level
subform is null AND another field on that same subform is
not null. I tried the following, but to no avail...I
guess I'm missing something basic (I'm fairly new at
Access):

=IIf(IsNull([Forms]![Subform1]![Subform2]![Field1]) And
Not IsNull([Forms]![Subform1]![Subform2]!
[Field2]),"Result1","Result2")

Any help out there?

.
 
S

SteveS

Linkerbink said:
I have a form and two subforms. I want a field on the
form to display a result if one field on the lowest level
subform is null AND another field on that same subform is
not null. I tried the following, but to no avail...I
guess I'm missing something basic (I'm fairly new at
Access):

=IIf(IsNull([Forms]![Subform1]![Subform2]![Field1]) And
Not IsNull([Forms]![Subform1]![Subform2]!
[Field2]),"Result1","Result2")

Any help out there?


You are not referring to the subforms correctly. See

"Refer to Form and Subform properties and controls" at

http://mvps.org/access/forms/frm0031.htm

Try this:

=IIF(IsNull(Me!Subform1.Form!Subform2.Form!Field1) AND Not
IsNull(Me!Subform1.Form!Subform2.Form!Field2),"Result1","Result2")
 

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