P
PeteCresswell
I've just been through the "Error3048: Cannot open any more databases"
thing.
Seems like DbEngine(0)(0).OpenRecordset allows one to open more tables
- either linked or internal - than CurrentDB().OpenRecordset.
That being the case, is there any reason to use CurrentDB
().OpenRecordset .... ever...?
e.g.
Public Function Error3048Test() As String
On Error GoTo Error3048Test_err
' PURPOSE: To explore relationship of "Error3048: Cannot open any more
databases" to
' CurrentDB() vs DBEngine(0)(0) when opening recordsets
'
' NOTES: 1) With a non-linked table, the number of open tables seems
tb
' 243 with CurrentDB and 403 with DbEngine
' 2) With a linked table, the number of open tables allowed
' appears to drop to 81 with CurrentDB and drop to 122
' with DbEngine(0)(0)
Dim thisDB As DAO.Database
Dim i As Long
Dim myMsg As String
Dim myRS(1000) As DAO.Recordset
Set thisDB = DBEngine(0)(0)
For i = 1 To 1000
' myMsg = " (CurrentDB, Internal)"
' Set myRS(i) = CurrentDb.OpenRecordset("Select * from
zstblDummy_SingleRecord", dbOpenDynaset) 'Internal to the app
' myMsg = " (DbEngine Internal)"
' Set myRS(i) = thisDB.OpenRecordset("Select * from
zstblDummy_SingleRecord", dbOpenDynaset) 'Internal to the app
' myMsg = " (CurrentDB, Linked)"
' Set myRS(i) = CurrentDb.OpenRecordset("Select * from
zstblRecordNumbers", dbOpenDynaset) 'Linked
myMsg = " (DbEngine, Linked)"
Set myRS(i) = thisDB.OpenRecordset("Select * from
zstblRecordNumbers", dbOpenDynaset) 'Linked
Next i
Error3048Test_xit:
Error3048Test = i & myMsg
On Error Resume Next
For i = 1 To 1000
myRS(i).Close
Set myRS(i) = Nothing
Next i
Set thisDB = Nothing
Exit Function
Error3048Test_err:
Resume Error3048Test_xit
End Function
thing.
Seems like DbEngine(0)(0).OpenRecordset allows one to open more tables
- either linked or internal - than CurrentDB().OpenRecordset.
That being the case, is there any reason to use CurrentDB
().OpenRecordset .... ever...?
e.g.
Public Function Error3048Test() As String
On Error GoTo Error3048Test_err
' PURPOSE: To explore relationship of "Error3048: Cannot open any more
databases" to
' CurrentDB() vs DBEngine(0)(0) when opening recordsets
'
' NOTES: 1) With a non-linked table, the number of open tables seems
tb
' 243 with CurrentDB and 403 with DbEngine
' 2) With a linked table, the number of open tables allowed
' appears to drop to 81 with CurrentDB and drop to 122
' with DbEngine(0)(0)
Dim thisDB As DAO.Database
Dim i As Long
Dim myMsg As String
Dim myRS(1000) As DAO.Recordset
Set thisDB = DBEngine(0)(0)
For i = 1 To 1000
' myMsg = " (CurrentDB, Internal)"
' Set myRS(i) = CurrentDb.OpenRecordset("Select * from
zstblDummy_SingleRecord", dbOpenDynaset) 'Internal to the app
' myMsg = " (DbEngine Internal)"
' Set myRS(i) = thisDB.OpenRecordset("Select * from
zstblDummy_SingleRecord", dbOpenDynaset) 'Internal to the app
' myMsg = " (CurrentDB, Linked)"
' Set myRS(i) = CurrentDb.OpenRecordset("Select * from
zstblRecordNumbers", dbOpenDynaset) 'Linked
myMsg = " (DbEngine, Linked)"
Set myRS(i) = thisDB.OpenRecordset("Select * from
zstblRecordNumbers", dbOpenDynaset) 'Linked
Next i
Error3048Test_xit:
Error3048Test = i & myMsg
On Error Resume Next
For i = 1 To 1000
myRS(i).Close
Set myRS(i) = Nothing
Next i
Set thisDB = Nothing
Exit Function
Error3048Test_err:
Resume Error3048Test_xit
End Function