Calculated field referencing subform field

G

Guest

Hi

I'm trying to indicate on a main form, whether a field on its subform contains data. The formula I am using is

=IIf(IsNull([CFirstName]),"No","Yes"

The result is No in all cases, even if CFirstName contains a data value. What is interesting is that if I put the same formula on the subform, the correct string will be returned

How can I make this work on the main form

Thanks
Jody
 
G

Graham Mandeno

Hi Jody

If [CFirstName] is on a subform, then you must reference it via the subform
control:

=IIf(IsNull([SubformControlName].Form![CFirstName]),"No","Yes")

Note that this the name of the *subform control* on your main form, which is
not necessarily the same as the name of the *form object* that is contained
within the control..

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Jody said:
Hi,

I'm trying to indicate on a main form, whether a field on its subform
contains data. The formula I am using is:
=IIf(IsNull([CFirstName]),"No","Yes")

The result is No in all cases, even if CFirstName contains a data value.
What is interesting is that if I put the same formula on the subform, the
correct string will be returned.
 
G

Guest

Thanks Graham. I tried your suggested code and got a #Name? error instead of a value. I made sure I followed your syntax exactly including the distinction between subform control and subform

Does the fact that I was getting a value originally (albiet, the wrong one), give some sort of clue

Thanks
Jod
 

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