New employees

  • Thread starter Thread starter Tom H.
  • Start date Start date
T

Tom H.

I'm not sure how to ask this question and I'm basically
learning Access as I go. I have created a small database
that stores employee information in a table. I have
created a form that allows me to enter new employee
information into the table. However, when I input the
employee information into the form for someone already
entered into the database, I get the error when I hit the
Enter key telling me that the entry already exists in the
form because the employee number is the unique primary
key. This is all well and good; however, I would like to
know that this employee number is in the database right
after I enter the number which is the first thing on the
form. I really don't want to wait until after I've typed
all of the information. There's got to be a better way.
 
Tom,
On the AfterUpdate event for your EmpID field, try a Refresh or Requery.
That will cause the "dupe" error to immediately display.
 
The problem is that your combo box is bound to a primary key (EmployeeID).
The solution is to make the combo box UNBOUND. Now Access won't think you
are adding a new employee so won't worry about duplicating the primary key.
So, in the combo box, leave the Control Source blank. Name the combo box
EmployeeSelect. In the AfterUpdate event click on the elipses, select Code
Builder, and enter the following code:

DoCmd.GoToControl "EmployeeID" (or whatever the primary key is
named.....quotes are required)
DoCmd.FindRecord Me![EmployeeSelect]

The EmployeeID field must be located on the form.

Contact me if any more help is needed.

Con Giacomini
(e-mail address removed)
 
Back
Top