Solved

Retrieve information from table in an unbound text box

Posted on 2011-02-22
10
277 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
  • 5
  • 5
10 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
ID: 34952340
sorry

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


change nameOFForm with the actual name of the form
0
 

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 119

Expert Comment

by:Rey Obrero
ID: 34952617
i didn't see you mentioned a subform in your original post..??
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

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

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

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero earned 500 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now