Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF function with a refrnce to a query?

Status
Not open for further replies.
Aug 2, 2000
325
US
Here is my function (on a form called Form2)

=IIf([Forms]![Form1]![cboValueA] Is Null,[MemberID],[Forms]![Form1]![cboValueA])

I need it to check the value of cboValueA if it's null then grab the value of the field MemberID from a query called "Query1", If it's not null then go ahead and use the value of cboValueA.

But this syntax returns "#Error"

Any Help would Whelp a heap.
Thanks
Dave
 
Try this one Dave:

=IIf(IsNull("[cboValueA]"),[MemberID],[cboValueA])

Should do it!
Gord
ghubbell@total.net
 
Thanks for the response, however now I'm getting the #Name error.
?????
 
Sorry Dave, my typing error. Should be:

=IIf(IsNull("cboValueA"),[MemberID],[cboValueA]) Gord
ghubbell@total.net
 
I'm still getting the error.

when I use something like

=IIf(IsNull([Forms]![Form1]![cboValueA]),"dude",[Forms]![Form1]![cboValueA])

the string "dude" will populate if cboValueA is null. But I want to display a field in a query instead of the string "dude". I have tried [Query1]![MemberID]. But I'm thinking that there needs to be [Queries]![Query1]![MemberID]. Much like the way cboValueA is being referenced. What do you think?
 
Gord, don't you mean:
=IIf(IsNull([cboValueA]), [MemberID], [cboValueA])

And actually, there's a shortcut way to do this:
=Nz([cboValueA], [MemberID])

Nz() returns the first argument if it is not null, else it returns the second argument. Rick Sprague
 
Thats what I mean! Thanks Rick! Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top