?
Solved

Retrieve information from table in an unbound text box

Posted on 2011-02-22
10
Medium Priority
?
286 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:smods
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34952077
use a dlookup() function

=nz(dlookup("ColumnName","tbl_table1","EmployeeName='" & me.textEmployeeName & "'"))
0
 

Author Comment

by:smods
ID: 34952236
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34952340
sorry

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


change nameOFForm with the actual name of the form
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:smods
ID: 34952491
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34952617
i didn't see you mentioned a subform in your original post..??
0
 

Author Comment

by:smods
ID: 34952716
Grrr, my bad! Sorry

Is there a way around this?  Points increased to 500
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34952776
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
 

Author Comment

by:smods
ID: 34952911
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
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 34953015
test this

=nz(DLookUp("Employee_Number","tbl_CashierDetails","Cashier='" & Forms![frm_New_KPI_Main]![frm_KPI_Sub].Form!textCashier & "'"))
0
 

Author Closing Comment

by:smods
ID: 34953075
Brilliant

Thanks
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question