codice:
Private Sub Form_Unload(Cancel As Integer)
On Error GoTo Err_Form_Unload
    If (AS400Rs.State = adStateOpen) Then
        AS400Rs.Close
    End If
    If (AS400Cn.State = adStateOpen) Then
        AS400Cn.Close
    End If
    Set AS400Rs = Nothing
    Set AS400Cn = Nothing
    Set frmAvvio = Nothing

    Exit Sub
Err_Form_Unload:
    call WriteLog ("FORMUNLOAD" & err.Number & "   " & err.Description)
End Sub
prova così