A
Andrew
Hi,
I have a large table (Tbl) that contains 450 000 records and 200 fields.
There are 5 Departments in it (feild Dept) and I want to create 5 tables from
it.
I have been able to do this using the following code:
Private Sub Btn_Produce_Commitment_Tables_Part_1()
On Error Resume Next
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
DoCmd.SetWarnings False
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM Qry_Summary_Of_Departments")
With rst
Do Until .EOF
sSQL = "SELECT Tbl_Range_By_Season_Data.* INTO
Tbl_Commitments_Data_" & !Dept & " "
sSQL = sSQL & "FROM Tbl_Range_By_Season_Data "
sSQL = sSQL & "WHERE (((Tbl_Range_By_Season_Data.Dept)=" & !Dept
& "));"
DoCmd.RunSQL sSQL
DoCmd.OpenQuery "Qry_Make_Table_Tbl_Summary_Of_Business_Groups_And_Depts"
' Call Btn_Produce_Commitment_Tables_Part_2
.MoveNext
Loop
Found_Last:
.Close
End With
' sSQL = "DELETE Tbl_Range_By_Season_Data_Temp.* FROM
Tbl_Range_By_Season_Data_Temp;"
' sSQL = "DELETE Tbl_Summary_Of_Business_Groups_And_Depts.* FROM
Tbl_Summary_Of_Business_Groups_And_Depts;"
Set qdf = Nothing
Set rst = Nothing
Set dbs = Nothing
End Sub
This process takes quite some time to run as I THINK it needs to open the
rst each time and check then write each record individually. It takes 15
minutes to do each Department.
Is there any way to speed it up? If it was Excel I'd sort it by department
and find the first occurrance of a new department and the last then highlight
the range, copy and paste into a new sheet. Is there an equivelant method
available.
I have a large table (Tbl) that contains 450 000 records and 200 fields.
There are 5 Departments in it (feild Dept) and I want to create 5 tables from
it.
I have been able to do this using the following code:
Private Sub Btn_Produce_Commitment_Tables_Part_1()
On Error Resume Next
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
DoCmd.SetWarnings False
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM Qry_Summary_Of_Departments")
With rst
Do Until .EOF
sSQL = "SELECT Tbl_Range_By_Season_Data.* INTO
Tbl_Commitments_Data_" & !Dept & " "
sSQL = sSQL & "FROM Tbl_Range_By_Season_Data "
sSQL = sSQL & "WHERE (((Tbl_Range_By_Season_Data.Dept)=" & !Dept
& "));"
DoCmd.RunSQL sSQL
DoCmd.OpenQuery "Qry_Make_Table_Tbl_Summary_Of_Business_Groups_And_Depts"
' Call Btn_Produce_Commitment_Tables_Part_2
.MoveNext
Loop
Found_Last:
.Close
End With
' sSQL = "DELETE Tbl_Range_By_Season_Data_Temp.* FROM
Tbl_Range_By_Season_Data_Temp;"
' sSQL = "DELETE Tbl_Summary_Of_Business_Groups_And_Depts.* FROM
Tbl_Summary_Of_Business_Groups_And_Depts;"
Set qdf = Nothing
Set rst = Nothing
Set dbs = Nothing
End Sub
This process takes quite some time to run as I THINK it needs to open the
rst each time and check then write each record individually. It takes 15
minutes to do each Department.
Is there any way to speed it up? If it was Excel I'd sort it by department
and find the first occurrance of a new department and the last then highlight
the range, copy and paste into a new sheet. Is there an equivelant method
available.