ms access - Use data entry form and auto populate certain fields -
i have 2 tables, let's call them employees
, customers
.
employees
pretty basic:
id | title | emp_name | building | email | phone
customers
not different:
id | cust_name | address | phone | emp_title | emp_name
i have form used data entry customers
. 2 of fields employee_title
, employee_name
.
employee_name
combo box control source employee_name
, row source select [employees].emp_name employees;
. there after update event requerys employee_title
.
for employee_title
control source =dlookup("title","employees","emp_name = '" & [employee_name] & "'")
.
this works fine form itself. after selecting employee's name dropdown, displays employee's title correctly. however, employee's title not inserted customers
table (everything else inserted correctly). not familiar ms access, i'm 99% sure because control source dlookup , not reference table.
so, how employee's title show on form , insert customer's table?
you need use little vba handle properly.
first, set control source of employee_title
emp_title
(or title
, or employee_title
, question bit vague name of column).
then, add following code employee_name
combo box.
private sub employee_name_afterupdate() employee_title = dlookup("title","employees","emp_name = '" & employee_name & "'") end sub
Comments
Post a Comment