I have a table in MS Access that has +17K of records. I am trying to break down that table into smaller tables of 500 records each. Using the following code, I am able to create the temp table, but I cannot reset the number of ID column. The ID column on the original table is an autonumber. I am trying to reset the ID field on the temp table so I can do a record search starting at 1 and going to 500.
The alter SQL that I have does not update/reset the temp table's ID column to 1. Any ideas?
The alter SQL that I have does not update/reset the temp table's ID column to 1. Any ideas?
Code:
Function SplitTables_Actual() Dim rs As New ADODB.Recordset Dim cn As New ADODB.Connection Set cn = CurrentProject.Connection Dim rowcount As Long Dim tblcount As Integer Dim i As Integer SQL = "SELECT * INTO tmp_Flush_Actual FROM BIG_Table" DoCmd.RunSQL SQL SQL = "ALTER TABLE tmp_Flush_Actual ALTER COLUMN ID COUNTER(1,1)" DoCmd.RunSQL SQL SQL = "SELECT count(*) as rowcount from BIG_Table" rs.Open SQL, cn rowcount = rs!rowcount rs.Close tblcount = rowcount / 500 + 1 For i = 1 To tblcount SQL = "SELECT * into tmp_flush_Actual" & i & " FROM tmp_Flush_Actual" & _ " WHERE ID <= 500*" & i DoCmd.RunSQL SQL SQL = "DELETE * FROM tmp_Flush_Actual" & _ " WHERE ID<= 500*" & i DoCmd.RunSQL SQL Next i End Function
Comment