F
Fred Baltus
Hi all,
I have read thet post about resetting the autonumber, but i got an error
message that the table is in use by an other person or proces. I have to
import data from excel and add automaticly an id to it for showing which rows
contains an error, when i proces the records in an other module.
Here is my code...
Private Sub cmdInlezenMedViewV2_Click()
Dim stPlaatsBestand, stNaamBestand As String
Dim stDocName As String
Dim dbs As Database
Dim rstComplicatie As Recordset
Set dbs = CurrentDb()
Set rstComplicatie = dbs.OpenRecordset("complicaties_v2", dbOpenDynaset)
Set rstInstelling = dbs.OpenRecordset("select * from instellingen_v2")
'get first record: name and folder of import-file
rstInstelling.MoveFirst
'make filename
stDocName = rstInstelling![PlaatsImportBestand] + "\" +
rstInstelling![NaamImportBestand]
'delete old records
CurrentDb.Execute "DELETE FROM complicaties_v2", dbFailOnError
'Import data from complicaties_v2
DoCmd.TransferSpreadsheet acImport, , "complicaties_v2", stDocName, True
End Sub
Just before CurrentDb.Execute "DELETE FROM complicaties_v2", dbFailOnError I
added : CurrentDb.Execute "ALTER TABLE complicaties_v2 ALTER COLUMN Id
COUNTER (0, 1)", dbFailOnError
but this doesn't work.
What I'm doing wrong?
Thanks,
Fred
I have read thet post about resetting the autonumber, but i got an error
message that the table is in use by an other person or proces. I have to
import data from excel and add automaticly an id to it for showing which rows
contains an error, when i proces the records in an other module.
Here is my code...
Private Sub cmdInlezenMedViewV2_Click()
Dim stPlaatsBestand, stNaamBestand As String
Dim stDocName As String
Dim dbs As Database
Dim rstComplicatie As Recordset
Set dbs = CurrentDb()
Set rstComplicatie = dbs.OpenRecordset("complicaties_v2", dbOpenDynaset)
Set rstInstelling = dbs.OpenRecordset("select * from instellingen_v2")
'get first record: name and folder of import-file
rstInstelling.MoveFirst
'make filename
stDocName = rstInstelling![PlaatsImportBestand] + "\" +
rstInstelling![NaamImportBestand]
'delete old records
CurrentDb.Execute "DELETE FROM complicaties_v2", dbFailOnError
'Import data from complicaties_v2
DoCmd.TransferSpreadsheet acImport, , "complicaties_v2", stDocName, True
End Sub
Just before CurrentDb.Execute "DELETE FROM complicaties_v2", dbFailOnError I
added : CurrentDb.Execute "ALTER TABLE complicaties_v2 ALTER COLUMN Id
COUNTER (0, 1)", dbFailOnError
but this doesn't work.
What I'm doing wrong?
Thanks,
Fred