I have a large table (~600,000 records) that needs to have a unique record number assigned to each number. The table itself is too large to add an autonumber field to directly, so I was trying to get around that through VBA.
I have a function that will go through the table's recordset and assign a number to each record. The problem is that it crashes at around 180,000 (and irrecoverably damaged the VBA module - it wouldn't even allow me to delete it.)
In troubleshooting the problem I noticed that as the function runs, the size of the database increases greatly, and the crash is caused by Access hitting the 2gb database limit. I'm wondering if the increased size is due to Access trying to keep everything in one transaction, and if I could tell it to somehow forget about remembering everything and just go ahead and make the changes. Something like a 'commit immediate' mode.
This is the entirety of the VBA module, I call this function directly from the immediate window since it only needs to happen once:
Any idea how I can cause this not to bloat horribly out of control?
I have a function that will go through the table's recordset and assign a number to each record. The problem is that it crashes at around 180,000 (and irrecoverably damaged the VBA module - it wouldn't even allow me to delete it.)
In troubleshooting the problem I noticed that as the function runs, the size of the database increases greatly, and the crash is caused by Access hitting the 2gb database limit. I'm wondering if the increased size is due to Access trying to keep everything in one transaction, and if I could tell it to somehow forget about remembering everything and just go ahead and make the changes. Something like a 'commit immediate' mode.
This is the entirety of the VBA module, I call this function directly from the immediate window since it only needs to happen once:
Code:
Function NumberTables(TableName)
Dim rs As Recordset
On Error Resume Next
DoCmd.SetWarnings False
DoCmd.RunSQL "ALTER TABLE [" & TableName & "] ADD COLUMN [Record_ID] INTEGER;"
If Err = 3380 Then Exit Function
On Error GoTo 0
Set rs = CurrentDb.TableDefs(TableName).OpenRecordset
rs.MoveFirst
Do While Not rs.EOF
Count = Count + 1
rs.Edit
rs.Fields("Record_ID") = Count
rs.Update
rs.MoveNext
Loop
rs.Close
End Function
Comment