I have split a database with the app local and data on network. I had a problem with my form receiving a duplicate value error on the autonumber field when 2 users made a new record. I have since changed the data type of the autonumber field to number and added the following code to my form:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
On Error Resume Next
Me![Job ID].DefaultValue = Nz(DMax("[Job ID]", "Job",0) + 1
End If
Now, when user #1 adds a record, it takes the next number ok, but user#2 creates a new record, it takes the same number. When the first user moves on to another record it is fine, but when user #2 attempts to move on, it receives the duplicate error again.
Any suggestions?
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
On Error Resume Next
Me![Job ID].DefaultValue = Nz(DMax("[Job ID]", "Job",0) + 1
End If
Now, when user #1 adds a record, it takes the next number ok, but user#2 creates a new record, it takes the same number. When the first user moves on to another record it is fine, but when user #2 attempts to move on, it receives the duplicate error again.
Any suggestions?