I think you already have the code for this to open a connection and recordset. So open those outside the loop. Then in the loop, put your code to create a single record. Then do this:
Dim i, iNoOfUnits As Integer
Take variables
iNoOfUnits = 5000
Create Connection
Create Recordset
set counter to 0
i = 0
'Since i = 0, then you can loop until i = 5000, which will loop from 0 - 4999.
Do Until i = iNoOfUnits
sUnit = "Q-RABA-2/29/07(1)-" & i
rs.AddNew
rs("Field1") = sUnit
...
rs.Update
i = i + 1
Loop
rs.Close
cn.Close
Regardless of whether you use a For Next, or Do Until Loop, ALWAYS increment the counter, otherwise you will create a million records all with the same values until you just have to dump the database. The increment is the i = i + 1.
Did that help?
mmcdonal
|