R
rml
I'm using the following code to create number + one. It works fine. On my
form, the user clicks this button and the number is generated. This is a
network situation. Sometimes, we see the number duplicated? Is there any
code I can add to prevent this form happening? Thanks.
Private Sub Command95_Click()
Dim X As Variant
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("Numbers")
rs.MoveLast
X = DMax("[number]", "[Numbers]") + 1
Me![Spectra] = DMax("[number]", "[Numbers]")
rs.AddNew
rs.Fields(0).Value = X
rs.Update
End Sub
form, the user clicks this button and the number is generated. This is a
network situation. Sometimes, we see the number duplicated? Is there any
code I can add to prevent this form happening? Thanks.
Private Sub Command95_Click()
Dim X As Variant
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("Numbers")
rs.MoveLast
X = DMax("[number]", "[Numbers]") + 1
Me![Spectra] = DMax("[number]", "[Numbers]")
rs.AddNew
rs.Fields(0).Value = X
rs.Update
End Sub