Auto fill in a form

G

Guest

In my form I have Employee ID, Last Name, First Name, Birth Date, and Hire
Date. I have a table with all this information in. On my form I want to have
my first combo box be "Employee ID" which is their employee number and the
primary key in my table. Within this that combo box I want to be able to go
through my combo box by last name but when I select it I want the employee
Number to be inputed. I also want my next four boxes (Last Name, First Name,
Birth Date and Hire Date) to auto fill. Can some tell me how to go about
this. Thanks in advance. Travis.
 
N

Nikos Yannacopoulos

Travis,

While in form design, select the combo box and open the properties
window (if not already open). Select tab Data; property Row Source Type
should be Table/Query, leave as is if yes, or change otherwise; delete
whatever is the current setting for property Rowsource, and with the
cursor in it click on the little button with the ellipse sign (three
dots) on the right, to invoke the query builder; in the query design
view, select the employees table and get these fields down to the grid:
Employee ID, last name, first name, birth date, hire date. Add any
sorting that you may want, close the query design window and confirm to
save the SQL query. back in form design, set the combo's Bound column
property to 1 if different (so it returns the Employee ID). Now, on tab
Format, put something like 1;1;1;0;0 (or whatever instead of 1) in the
Column Widths property, the effect of which is that the user only sees
the second and third colun (last name, first name) even though the
others are still there. Adjust the combo's width so it will only display
the first column (employee ID) while not dropped down. This concludes
the work on the combo. The reason why you added the non-visible date
columns as well is so you can use them to display the dates in the
unbound text boxes, jsut like you will do with the last and first name.
To do so, you will utilize the column property of the combo, which is
zero based (first column is index 0). So, in the properties for the last
name textbox, tab data, set Control Source to:
[Employee ID].Column(1)
where I have assumed the combo name to be also Employee ID; change if
different. Likewise, [Employee ID].Column(2) for the first name etc.
This way all four unbound textboxes will be updated every tiem the user
makes a change in the combo.

HTH,
Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top