0

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.

1
Contributor
1
Reply
3
Views
10 Years
Discussion Span
Last Post by dilip_singh3
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.