Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding "name" to form DLookup?

Status
Not open for further replies.

Spott

Technical User
Mar 11, 2002
21
0
0
US
I'm working on a form that pulls up training data linked to an employee number (from odbc table) I need to get the name to show up, so we can tell who's sheet we're looking at. If we just drop the name in, it locks the data so it can't be edited. I'm trying a dlookup

=DLookUp("[Name]","[New Active Employee Query]","[emp_id]=[emp_id]")

Look up name from new active employee query where emp id from the form = emp id from the query - I think...

This pulls up the first person alphabetically for every record! Other variations I've tried pulls up nothing or errors. It's stumped me and my resident expert and would love any ideas to make this work!
 
Create a textbox. Put the following on the AfterUpdate event of your textbox that will show the employeeID:

Private Sub EmployeeID_AfterUpdate()
Dim Employinfo As Recordset, SQLText
SQLText = "Select [EmployeeName] From [EmployTableName] Where [EmployeeID] = " & Me![EmployeeID]
Set Employinfo = CurrentDb.OpenRecordset(SQLText)
Me![EmployeeName] = Employinfo![EmployeeName]
End Sub

Type SQLText on one line.
Substitute: EmployeeName with your field name
EmployTableName with your table name
The first [EmployeeID] with the name of the TEXT BOX
EmployeeID in Me![EmployeeID] with the name of your FIELD.

Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top