I am using DAO with an Access 2000 database. One of the tables contains the field "Code", a numeric value. I use the following code to find the first number that is not found in the table (for certain reasons I can't use autonumber, otherwise this would not be a problem)
The problem is that when there are 2 users logged in simultaneously and both of them add a record, both records are added with the same Code. I have tried various requery, refresh, etc. methods with no luck.Code:Dim NewCode as Integer NewCode = 1 rsContacts.FindFirst "CODE = " & NewCode Do Until rsLogrosTipos.NoMatch = True rsLogrosTipos.FindFirst "CODE = " & NewCode If rsLogrosTipos.NoMatch = False Then NewCode = NewCode + 1 End If Loop rsContacts.AddNew rsContacts.Fields("CODE") = NewCode rsContacts.Update
Any help would be appreciated.
Thank you,
Andrew




Reply With Quote