Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with automatic numbering

Status
Not open for further replies.

chirpyform

Programmer
Jun 20, 2003
202
FR
I am currently working with Access 2000 and have in my database the code below which imports the data from another database. However, I import 2300 lignes into the table (with the key of the table at 2300) but the automatic numbering offers me 1700 as the next number. This obviously causes problems because this identifiant already exists. If I delete all the lignes with an identifiant greater than 1700 Access continues normally.

This happens in only one table and didn't happen when I worked with Access 97.

Can anyone help please ??

For Each TableSel In ListeSel.ItemsSelected
strOut = ""
NomTable = ListeSel.ItemData(TableSel)

Set RecSet = db.OpenRecordset(NomTable)
Set RecSetImport = DbImport.OpenRecordset(NomTable)

If RecSetImport.RecordCount <> 0 Then
var = RecSetImport.GetRows(RecSetImport.RecordCount)
NbCol = UBound(var, 1) + 1
NbLigne = UBound(var, 2) + 1
Cpt1 = 0
Cpt2 = 0

While Cpt1 < NbLigne
RecSet.AddNew
While Cpt2 < NbCol
RecSet.Fields(Cpt2) = var(Cpt2, Cpt1)
Cpt2 = Cpt2 + 1
Wend
RecSet.Update
Cpt1 = Cpt1 + 1
Cpt2 = 0
Wend
End If
Print #Numlog, strOut

Next TableSel
 
some times a simple Compact and repair resolves this, but my preference would be to use my own auto number field.
 
Unfortunately there is already too much code based on the automatic numbering to change now.

Thanks Anyway

Does this happen often?
The strange thing is that it is always with the same table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top