Ciao memo63,
come ti è gia stato segnalato da Oregon devi usare la proprietà State, se vuoi la funzione da usare è la seguente:
- Da inserire in un Modulo Bas
codice:
'Verifica lo stato:
Public Function GetState(intState As Integer) As String
Select Case intState
Case adStateClosed
GetState = "adStateClosed"
Case adStateOpen
GetState = "adStateOpen"
End Select
End Function
Poi per chiudere la connessione ed il RS, nella routine corrente:
codice:
'Chiude e cancella il recordSet:
If GetState(RST.State) = "adStateOpen" Then
RST.Close
Set RST = Nothing
End If
'Chiude la connessione:
If GetState(Cns.State) = "adStateOpen" Then
Cns.Close
Set Cns = Nothing
End If
Ciao.