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!

Displaying information in a textbox using dlookup

Status
Not open for further replies.

chanman525

IS-IT--Management
Oct 7, 2003
169
0
0
US
Hey everyone. I just need a little help using dlookup. I've tried what seems to be 100 different combinations and can't seem to get it to work. Here's the scenario...

I have a table called emp.

Field2 is the employee name
Field5 is the employee id.

I want to be able to type in the employee id into the txtempid text box on the form, and display the name in the txtemployee text box.

Right now I have an event procedure set up on the after update option of the txtempid text box. My dlookup string is the following:

dlookup ("[Field5]", "[Emp]", "[Field2]=txtempid")

The debugger says it's expecting an = at the end. I'm at a loss on this one. Can anyone provide some insight?
 
Code:
txtemployee =dlookup ("[Field2]", "[Emp]", "[Field5]=" & txtempid)
 
I appreciate the response. The problem now is, when I try to run it, gives a runtime error 2001, You Canceled the previous operation. I've seen this before which makes me believe that I was close at one time, but couldn't get around this error. Any thoughts?
 
try this.

txtemployee = DLookUp ("Field2","Emp", "Field5='"&_
txtempid & "'")
 
it also helps if you check which data it's capturing..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top