G
George Papadopoulos
I am trying out an simple subroutine. My database has a table named
'Books'. I have written the code below.
Sub exaRecordsets()
Dim db As Database
Dim rsTable As Recordset
Dim rsDyna As Recordset
Dim rsSnap As Recordset
Set db = CurrentDb
' Open table-type recordset
Set rsTable = db.OpenRecordset("BOOKS")
Debug.Print "TableCount: " & rsTable.RecordCount
' Open dynaset-table recordset
Set rsDyna = db.OpenRecordset("Books", dbOpenDynaset)
Debug.Print "DynaCount: " & rsDyna.RecordCount
rsDyna.MoveLast
Debug.Print "DynaCount: " & rsDyna.RecordCount
' Open snapshot-type recordset
Set rsSnap = db.OpenRecordset("Books", dbOpenSnapshot)
Debug.Print "SnapCount: " & rsSnap.RecordCount
rsSnap.MoveLast
Debug.Print "SnapCount: " & rsSnap.RecordCount
' Close all
rsTable.Close
rsDyna.Close
rsSnap.Close
End Sub
which is included in a module named 'Module1'. I was trying to test the code
by calling the subroutine. Unfortunately I get the error 'Type mismatch'.
The problematic line has been traced to be
Set rsTable = db.OpenRecordset("BOOKS"). I believe that my database has not
been opened correctly by the statement 'db = CurrentdB'.
Any suggestions?
George Papadopoulos
'Books'. I have written the code below.
Sub exaRecordsets()
Dim db As Database
Dim rsTable As Recordset
Dim rsDyna As Recordset
Dim rsSnap As Recordset
Set db = CurrentDb
' Open table-type recordset
Set rsTable = db.OpenRecordset("BOOKS")
Debug.Print "TableCount: " & rsTable.RecordCount
' Open dynaset-table recordset
Set rsDyna = db.OpenRecordset("Books", dbOpenDynaset)
Debug.Print "DynaCount: " & rsDyna.RecordCount
rsDyna.MoveLast
Debug.Print "DynaCount: " & rsDyna.RecordCount
' Open snapshot-type recordset
Set rsSnap = db.OpenRecordset("Books", dbOpenSnapshot)
Debug.Print "SnapCount: " & rsSnap.RecordCount
rsSnap.MoveLast
Debug.Print "SnapCount: " & rsSnap.RecordCount
' Close all
rsTable.Close
rsDyna.Close
rsSnap.Close
End Sub
which is included in a module named 'Module1'. I was trying to test the code
by calling the subroutine. Unfortunately I get the error 'Type mismatch'.
The problematic line has been traced to be
Set rsTable = db.OpenRecordset("BOOKS"). I believe that my database has not
been opened correctly by the statement 'db = CurrentdB'.
Any suggestions?
George Papadopoulos