When using Access fields,
Set fld = rstOrders.Fields("fldCustomer")
for i = 1 to 100000
rstOrders.AddNew
fld = str(i)
rstOrders.Update
next
is much faster.
This is basically true for all collections which can be bound like
fields, e.g.
Option Compare Database
Option Explicit
Declare Function GetTickCount Lib "kernel32.dll" () As Long
Public Sub Test()
Const MAX_COUNT As Long = 100000
Dim db As DAO.Database
Dim td As DAO.TableDef
Dim count As Long
Dim dummy As String
Dim tcStart As Long
Dim tcStop As Long
Debug.Print "---"
Set db = CurrentDb
tcStart = GetTickCount
For count = 1 To MAX_COUNT
dummy = db.TableDefs.item(0).Name
Next count
tcStop = GetTickCount
Debug.Print "Time elapsed:"; tcStop - tcStart; "ms"
Set td = db.TableDefs.item(0)
tcStart = GetTickCount
For count = 1 To MAX_COUNT
dummy = td.Name
Next count
tcStop = GetTickCount
Debug.Print "Time elapsed:"; tcStop - tcStart; "ms"
End Sub
Don't know why it is called an Update Query. In other
RDMS's it would have been called a stored procedure.
Only when you store it there, otherwise it may be called adhoc query.
Some DBA's are afraid of these
mfG
--> stefan <--