Discussion Locked

Access 2000 Form Question

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am using Access 2000. I am trying to get a form field to auto generate a value based on what is entered in the field before it. For example if field 1 is employee_id and field 2 is employee_name, I am looking to have the employee_name field filledin according to the matching employee_id that is entered by the form user. Is this possible?

7 replies

by karpi

Hi,

yes it is possible.

Use the onUpdate-Event of employee_id an place the following code:

If Not IsNull(Me.employee_id) Then
a = DLookup("MyDBFieldEmployee_name", "MyEmployeeTable", "MyDBEmployeeidField=" & Me.employee_id)
End If

Pleas replace the My... with the according Field/Tablenames from your System

HTH
Karpi

by dakota99

Thanks for your help. I am having a little trouble following your example....

In your example: What does Me.employee_id stand for?
Also, there is no on update. The closest thin I found was before or after update. I tried the code in after updatewithout success.

I am a little confused...Please Help....

by karpi

OK,

the event is really "After Update". Sorry!

Here is some clarification:

MyDBFieldEmployee_name => is the Tablefield that holds the Name of the employee.

MyEmployeeTable => is the Name of the table that holds the Employee-Information.
MyDBEmployeeidField => is the tablefield that holds the employeeid

Me.employee_id => is the formfield that holds the user-entered employee-id

a => is the formfield that holds the name of the employee

This statement simply means Lookup a field (MyDBFieldEmployee_name) in a table (MyEmployeeTable) with a restriction (in the row where the employee_id is equal to the user-entered value from employee_id)

HTH
Karpi

by phingers

2 tables - one for employee data and one for the employee ID. ID is the primary key, relationship between them of one-to-many on employee ID. Set your form to be based on a query that pulls the employee data and the ID from the employees table, and the employee name from the ID table. Base your form on the query, now if you enter an employee ID the form should get the name from the right place automatically? hope this helps!

This discussion is closed to new replies.