Solved How to hide the #error in an unbound DLookup field (1 Viewer)

brandywinefarm

New member
Local time
Today, 10:41
Joined
Jan 27, 2023
Messages
4
Hello.
I have a form that has a drop down box that looks up the referrerID from a contact table (integer).
Then I have an unbound field that reports that person's name for the user.
It works fine. However, if there is no one that referred that client, the referrerID field is null and so the unbound field shows "#error".
Control source for that unbound field =DLookUp("[FirstName] & ' ' & [LastName]","people","peopleid=" & [frmReferrerID])
Is there any way I can hide this text so the data entry person doesn't get confused by this #error?
I have searched and tried a few code snippets but nothing seems to work.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:41
Joined
May 7, 2009
Messages
19,245
try:

=DLookUp("[FirstName] & ' ' & [LastName]","people","peopleid=" & Nz([frmReferrerID],0)) & ""
 

brandywinefarm

New member
Local time
Today, 10:41
Joined
Jan 27, 2023
Messages
4
That works. Please help me understand. Before I tried to use ISNULL to return a "" into the field but it never worked.
Isn't it proper to use ISNULL on a blank integer field?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:41
Joined
Feb 28, 2001
Messages
27,191
Stated another way, the NZ function "hides" the actual ISNULL test behind the scenes and performs the substitution if ISNULL would be TRUE. By hiding the test, NZ lets you make a safer operation that will avoid the pitfalls of null encounters.
 

Users who are viewing this thread

Top Bottom