Article ID: 109830
Article Last Modified on 10/30/2003
Sub Form_Load ()
Dim Starttime, Endtime
Dim db As Database
Dim t As Table
Dim i As Integer
Dim tempName As String
Dim temphone As String
Set db = OpenDatabase("c:\BIBLIO.MDB") ' Uses a copy of BIBLIO.MDB
Set t = db.OpenTable("Publishers")
Starttime = Now
'BeginTrans ' Add this and CommitTrans (below) for greater speed.
For i = 1 To 100
tempName = "testname" & Str$(i) 'Make an arbitrary unique string.
tempPhone = Str$(i) 'Make arbitrary number.
t.AddNew 'AddNew clears copy buffer to prepare for new record.
t!PubID = 30 + i ' Set primary key to unique value.
t!Name = tempName ' Set Name field to unique value.
t!Telephone = tempPhone ' Set Telephone field to unique value.
t.Update ' Write the record to disk or to transaction buffer.
Next i
'CommitTrans ' Add this and BeginTrans (above) for greater speed.
Endtime = Now
MsgBox "Time required= " & Format(Endtime - Starttime, "hh:mm:ss")
t.Close
db.Close
End
End Sub
The above code adds 100 new records to the BIBLIO.MDB database file.
Add the records to a copy of BIBLIO.MDB instead of to the original.
Additional query words: 3.00
Keywords: KB109830