rwwilliamson
New User
- Local time
- Today, 12:18
- Joined
- May 26, 2005
- Messages
- 11
Upon a user request, the following code gets executed to clean out and initialize the "Scores" table with a competitor number and an event number. Each competitor can have 20 event scores. A crosstab query is used to gather up all the appropriate scores for each competitor and calculate a final total score. The below code runs correctly, but the speed is abysmally slow and it takes 30+ seconds to initialize the 4000 records (200 competitors x 20 events). Is there a faster way to perform this simple action?
Function InitScores()
Dim dbsCurrent As Database
Dim EventNum As Integer, Competitor As Integer, i As Integer, j As Integer
Dim Scores As String
Set dbsCurrent = CurrentDb
Call dbsCurrent.Execute("delete *.* from Scores", dbFailOnError)
For i = 1 To 200 Step 1
For j = 1 To 20 Step 1
Call dbsCurrent.Execute("insert into Scores (Competitor, EventNum) values (" & i & ", " & j & " )")
Next
Next
End Function
Function InitScores()
Dim dbsCurrent As Database
Dim EventNum As Integer, Competitor As Integer, i As Integer, j As Integer
Dim Scores As String
Set dbsCurrent = CurrentDb
Call dbsCurrent.Execute("delete *.* from Scores", dbFailOnError)
For i = 1 To 200 Step 1
For j = 1 To 20 Step 1
Call dbsCurrent.Execute("insert into Scores (Competitor, EventNum) values (" & i & ", " & j & " )")
Next
Next
End Function