G Guest Apr 19, 2006 #1 Is there a way I can find out if a recordset is open? Specific VBA syntax please? Thanks a million!
B Brendan Reynolds Apr 20, 2006 #2 ADO recordsets have a State property which is equal to adStateClosed if the recordset is closed ... If Not mrst Is Nothing Then If mrst.State <> adStateClosed Then mrst.Close End If End If DAO recordsets do not have such a property. I use a Boolean variable to keep track of the state of DAO recordsets ... Set rst = db.OpenDatabase(strSQL) boolOpen = True .... rst.Close boolOpen = False .... If boolOpen Then rst.Close boolOpen = False End If
ADO recordsets have a State property which is equal to adStateClosed if the recordset is closed ... If Not mrst Is Nothing Then If mrst.State <> adStateClosed Then mrst.Close End If End If DAO recordsets do not have such a property. I use a Boolean variable to keep track of the state of DAO recordsets ... Set rst = db.OpenDatabase(strSQL) boolOpen = True .... rst.Close boolOpen = False .... If boolOpen Then rst.Close boolOpen = False End If