I am using MS Access database by a vb6 program for multiuser environment.
In the program I have written code for autogenerating employee_id which is primary key in the table.
When entering records simultaneously from two or more workstation,
It gives a problem

Run time error
The changes you requested to the table were not successful because they would create duplicate values in the primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.

How to resolve it.
Is there any way to restrict the database from accessing when record appending goes on by other workstation.

using the bold lines below in the code we can handle simultaneous access

Private Sub Command1_Click()
CNN.BeginTrans
If Not VALIDATE() Then Exit Sub
Call GENERATE_EMP_ID
CNN.Execute "INSERT INTO EM VALUES ('" + ID + "', '" + txt_code.Text + "', '" + txt_name.Text + "', " & Val(txt_basic.Text) & ")"
Call SET_DATA_TO_GRID
CNN.CommitTrans
MsgBox "EMPLOYEE ID IS : " + UCase(ID)
CLEAR_CONTROLS
End Sub