View Full Version : IFF with DLookup function produced #Name?


Lissa
04-30-2008, 01:45 PM
Hi All,
I was wondering if someone could point out what I'm doing wrong...
I have a (parent) form with 2 subforms. I would like the field in one subform to look at the value in the other subform... if that value is null I would like the field to display "N/A" otherwise I want it to perform a DLOOKUP....
I have the following but I'm not sure if I'm referencing the subform field correctly... I keep getting the #Name? when viewing the field from the parent form's display.

=IIf(IsNull(subfrmPROPOSALSetup.Form!LaborCategory 1),"N/A",DLookUp("LaborCategory1","LABOR","ProposalID=" & Forms!frmPROPOSALSetup!ProposalID))

Thanks in advance! :)

Kiwiman
04-30-2008, 02:20 PM
I have a similar one in one of my dbs. It could very well be your referencing of the subform and subform control

Try this...

Also should there be a gap in your "labourCategory 1"??


IIf(IsNull([Forms]![frmPROPOSALSetup]![subfrmPROPOSALSetup]![LaborCategory 1]),"N/A",DLookUp("LaborCategory1","LABOR","[ProposalID ]=" & Forms!frmPROPOSALSetup!ProposalID))


Here is mine - please adapt to your db as see if it works, if the above fails...

Main form is the frmClients
Sub form is the sfmSites
which in turn has a subform sfmSamples
IIf(IsNull([Forms]![frmClients]![sfmSites].[Form]![sfmSamples].[Form]![SampID]),"N/A",DLookUp("ClientName","tblClients","[Clientid]=" & [Forms]![frmClients]![LogId]))

Lissa
04-30-2008, 02:48 PM
Kiwiman -
Thanks for responding :) I tried your example and that didn't quite work but it made me think of something else to try...

This worked for me...

=IIf(IsNull(DLookUp("LaborCategory1","LABOR","[ProposalID ]=" & Forms!frmPROPOSALSetup!ProposalID)),"N/A",DLookUp("LaborCategory1","LABOR","[ProposalID ]=" & Forms!frmPROPOSALSetup!ProposalID))