Retrieve information from table in an unbound text box

Hi all,

What would I set an unbound text box control source to in order to get the third column from tbl_table1 where the text box employee matches the employee name in the table?

If there is nothing in the column then it should just remain blank.

Thanks

Chris
smodsAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
test this

=nz(DLookUp("Employee_Number","tbl_CashierDetails","Cashier='" & Forms![frm_New_KPI_Main]![frm_KPI_Sub].Form!textCashier & "'"))
0
 
Rey Obrero (Capricorn1)Commented:
use a dlookup() function

=nz(dlookup("ColumnName","tbl_table1","EmployeeName='" & me.textEmployeeName & "'"))
0
 
smodsAuthor Commented:
Thanks capricorn1

The text box is just returning #Name?

I can't work out why.  I've amended the code as per my field names

=nz(DLookUp("Employee_Number","tbl_CashierDetails","Cashier='" & me.textCashier & "'"))
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Rey Obrero (Capricorn1)Commented:
sorry

=nz(DLookUp("Employee_Number","tbl_CashierDetails","Cashier='" & Forms!NameOfForm!textCashier & "'"))


change nameOFForm with the actual name of the form
0
 
smodsAuthor Commented:
No worries! I have done this and it works when you open the subform directly but not when you open the main form that the subform is in.  I still get #Name?

What would be the reason for this?

Regards

Chris
0
 
Rey Obrero (Capricorn1)Commented:
i didn't see you mentioned a subform in your original post..??
0
 
smodsAuthor Commented:
Grrr, my bad! Sorry

Is there a way around this?  Points increased to 500
0
 
Rey Obrero (Capricorn1)Commented:
ok,

where is the textbox that you want to display the  "Employee_Number" located?
where is the textbox  "textCashier" located?

what is the name of Main form? the name of the subform?
0
 
smodsAuthor Commented:
The text box where I want to display the employee number is on the subform.

The text box textCashier is also located on the subform.

The main form is called frm_New_KPI_Main

The subform in the main database window is called frm_New_KPI_Sub but the actual name of the subform when viewed inside the main form is called frm_KPI_Sub

Regards

Chris
0
 
smodsAuthor Commented:
Brilliant

Thanks
0
All Courses

From novice to tech pro — start learning today.