Nz and #Error

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
On my form I have two textboxes. The values for these textboxes are being pulled from a query. In this query, there are two fields labeled Badge_ID and FullName. When a Badge_ID is entered into the first textbox, I use the DLookUp to locate the matching Name for that Badge_ID number and place the FullName of that employee in the EmpName textbox. I found a YouTube video that shows how to do that and it showed to put the following code in the "Control Source" of the EmpName textbox.
VBA Code:
=DLookUp("FullName","FullName","Badge_ID=" & [EmployeeIDtxtbx])
The problem is when the form loads, #Error appears in the Employee_IDtxtbx. I saw another YouTube video that this can be fixed by using Nz (Null Zero) but I can't figure out where in that code to place it. Thank you.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
That may not be the issue as the error usually means the name of something can't be resolved. Your query name and the fullname field have the same name? If not, that's the problem. If they are the same, then try
=DLookUp("FullName","FullName","Badge_ID=" & Nz([EmployeeIDtxtbx],0))
That assumes you want to return a zero if FullName is Null and that BadgeID is number data type.
FWIW I would not name a field and the table/query the same name.
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top