I have a problem when I am setting the Seed of an AutoNumber using ADOX. VB report errors when VB executing the codes if 2 or more VB applications are connecting to the table. But if I remove the line (bellow Bold),then it come to be multi-instances.
oCat.Tables("tblFile").Columns("ID").Properties("Seed") = NewID + 1
Code:Dim oCnn As Object ' ADODB.Connection Dim oRS As Object Dim objJRO As Object Dim oCat As Object 'New ADOX.Catalog Dim NewID As Long 'this will contain the seed value. Dim hFile As Long ' Insert the object into the database On Error GoTo vbErrorHandler If Not InitDB(oCnn, Me.DatabaseName, Me.UserName, Me.Password) Then Exit Function Set oRS = CreateObject("ADODB.Recordset") ' New ADODB.Recordset 'reset the seed value of your AutoNumber field (the value of the new identity) Set oRS = oCnn.Execute("SELECT MAX(ID) FROM tblFile") NewID = oRS.Fields(0).Value '0 specifies that we want the first field oRS.Close Set oCat = CreateObject("ADOX.Catalog") ' New ADOX.Catalog oCat.ActiveConnection = oCnn oCat.Tables("tblFile").Columns("ID").Properties("Seed") = NewID + 1 oCat.Tables("tblFile").Columns.Refresh Set oCat = Nothing




Reply With Quote
