Can not open any more databases (1 Viewer)

evanscamman

Registered User.
Local time
Today, 00:28
Joined
Feb 25, 2007
Messages
274
I have been developing a database that is now in the implementation stage. Everything is functioning very well except that after working in the database for a couple of hours, I get this message: "Can not open any more databases." I think this may be from improperly calling and closing recordsets in VBA.

This is how I currently do it:

Code:
    Dim rs As DAO.Recordset, strSQL As String

    'Open Recordset to record in tblUOM
    strSQL = "SELECT tblItemUOM.*, tblItemUOM.ItemUOMID FROM tblItemUOM WHERE (((tblItemUOM.ItemUOMID)=" & lngUOM & "));"
    Set rs = CurrentDb.OpenRecordset(strSQL)

    If Not rs.EOF Then
        rs.MoveFirst
        'Do something here...
    End If

Cleanup:
    rs.Close
    Set rs = Nothing

Am I doing something wrong that is leaving a connection open?

Thank you,
Evan
 

Simon_MT

Registered User.
Local time
Today, 08:28
Joined
Feb 26, 2007
Messages
2,177
Try declaring the Database and add this in the appropriate places:

Dim db As DAO.Database
Set db = CurrentDb
Set db = Nothing

Simon
 

Users who are viewing this thread

Top Bottom