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!

Auto Fill Form Field

Status
Not open for further replies.

ewd97

MIS
Jan 24, 2004
16
0
0
US
I have an employee table that lists, among other things, Full_Name and Department. I have a form that is being used to populate another table(Daily_Sheet), that will allow you to type in a full_name and it will pull from the employee table to prevent mis-spellings. That is done and that was the easy part. I need a way that when an employee name is typed in on the form, it will also populate a field on the form with the employees department from the employee table. There are very few threads concerning this and most of the ones that I have read are very vague.

Any help will be appreciated.
 
Use the after update event property on the name field and then do a DLookup to fill in the department field.

Example:

Private Sub YourNameField_AfterUpdate()

YourDepartmentField = Dlookup("[DepartmentID]","tblEmployees","[EmployeeName]='" & YourNameField & "'")

End Sub

HTH
Mike

[noevil]
 
That sound easy enough, but what type of statement structure is the dlookup and how would I enter it. I know where the event afterupdate would be, but is it a macro, expression, or code?
 
It is a VBA Code so do [Event Procedure]

HTH
Mike

[noevil]
 
That worked better than I could have expected. Thank you for the help mgolla!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top