I have an ADO record set variable that is declared in a class module of a custom form. The recordset opens in the "Activate event" form, and I'm trying to close it in the "Finish" form with code like this:
Private Sub UserForm_Terminate() If VersionIsReleased Then ThisWorkbook.Parent.Quit Else If Not m_rs Is Nothing Then If m_rs.State = adStateOpen Then m_rs.Close End If Set m_rs = Nothing End If Close_CN g_cn ThisWorkbook.Application.Visible = True End If End Sub
The line m_rs.Close generates a run-time error: "Operation is not allowed in this context." Any ideas why this is happening?
source share