Article ID: 116034
Article Last Modified on 10/29/2003
Sub Command1_Click ()
Dim i As Integer
Dim db As database
Dim ss As snapshot
On Error GoTo Command1_ClickError
Set db = OpenDatabase("c:\vb\biblio.mdb")
BeginTrans
For i = 1 To 500
Label1.Caption = i
Label1.Refresh
Set ss = db.CreateSnapshot("SELECT * FROM Authors")
'
' Code to manipulate the Snapshot records would be here ...
'
ss.Close
Set ss = Nothing
Next i
Rollback
db.Close
Label1.Caption = Trim(Label1.Caption) & " Done!"
Label1.Refresh
Exit Sub
Command1_ClickError:
If Err <> 0 Then
' Enter the following two lines as one, single line:
MsgBox "Error: " & Trim(CStr(Err)) & Chr$(10) & Chr$(13)
& "Error: " & Trim(Error$)
Label1.Caption = Trim(Label1.Caption) & " FAIL!"
Label1.Refresh
Rollback
End If
Exit Sub
End Sub
Set ss = db.CreateSnapshot("SELECT * FROM Authors")
For i = 1 To 500
Label1.Caption = i
Label1.Refresh
'
' Code to manipulate the Snapshot records would be here ...
'
Next i
ss.Close
Set ss = Nothing
Because the snapshot is opened outside the loop, only one reference to the
underlying tables is created, so the "Can't open any more tables" error
does not occur.
Additional query words: 3.00 errmsg
Keywords: kbprb KB116034