Needing help automatically generating info from a table to a form

N

NNL

I'm creating a database for a project at work that will track production and
piece work. I've started with a
table that I have imported from Excel that contains the employee's clock
number and their name. I have created a form that allows supervisors to enter
in daily production data for each employee. However, I am trying to cut down
on as much typing as possible. So, I would like to create a box that allows
the user to enter in the employee clock number and when they tab down it will
automatically pull up the employee's name in a box next to it. I have been
messing around with it for days now and all I can get it to do is allow the
user to manually select the employee's name from a drop down box, which is
not what I'm wanting it to do. If anyone could help me out on this I would
GREATLY appreciate it. Thanks!
 
A

Arvin Meyer [MVP]

Try using a combo box which includes both the name and clock number. Only
the first non-zero width column will be displayed, so you set a textbox
controlsource to:

= ComboBoxName.Column(1)

where the second column is the one to display. The column width property is
zero based.
 
D

Dennis

NNL,

You can do what you are describing, but there is a better way to do it in
Windows and Access.

You can create a combo box where you can type in the first part of the
employee name and Access will automatically bring up just those employee
names that match what you have type in.

For example, let say setup the names to appear Last, First (you can just a
easily do First Last). When the user types in “Smiâ€, only those names that
start with “Smi†will appear in the drop down list. (Smi is just an example).

Does this sound like what you want to do?

Dennis
 
D

Dennis

NNL,

For the sake of this question, let assume the following:

Table Name: tblEmployee
Primary Key: ClockNo
First field: Employee Name

You can search on either the Clock No or Employee Name, that is your choice.

If you want to search on Employee Name and display the clock number, you
will have create the following control field names on your form:

A combo box called Me.cboEmployeeName
A text box called Me.txtClockNo

If you want to search on Clock Number and display the Employee Name, you
will have to create the following control field names on your form:

A combo box called Me.cboClockNo
A text box called Me.txtEmployeeName

When you create the combo box, Access will ask you if you want to select
from a table – make sure you choose that option.

You have to specify the following field in the source query:

Clock No, Employee Name

If you want to search on Clock Number and display the Employee Name, set the
field length to Clock Number to the appropriate value and set the Employee
Name length to 0â€. (A length of 0†will cause the field to NOT be displayed
on the form.)

If you want to search on Employee Name and display the Clock Number, set the
field length to Clock Number to 0†and set the Employee Name length to the
appropriate value.

In either case, you want Access to assign the Clock Number as the value of
the combo box variable. Remember, even though the value of the combo box
variable will be set to Clock No (which is the primary key) Access will
display the query source field which is NOT set to a length of 0â€.

To obtain the value that was not displayed, in the AfterUpdate event of the
combo box control, you will want to place the following code.

strClockNo = ComboBoxName.Column(1)
strEmployeeName = ComboBoxName.Column(2)

If you searched on the name and want to display the Clock No:

Me.txtClockNo = strClockNo

If you searched on the Clock No and want to display the nameâ€

Me.txtEmployeeName = strEmployeeName


Good luck.

Dennis
 
N

nlewallen via AccessMonster.com

Thanks so much! That did the trick!
Try using a combo box which includes both the name and clock number. Only
the first non-zero width column will be displayed, so you set a textbox
controlsource to:

= ComboBoxName.Column(1)

where the second column is the one to display. The column width property is
zero based.
I'm creating a database for a project at work that will track production
and
[quoted text clipped - 14 lines]
not what I'm wanting it to do. If anyone could help me out on this I would
GREATLY appreciate it. Thanks!
 

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