Hi to all the members list, my problem is in the unload event, when I run the form and then I click the "cancel" button the error is: "object required", perhaps if I insert a record, it works but when I click the cancel button I have the next error: "this operation is not permited when the object is open", so the bad sentences is: grs.ActiveConnection = Nothing, why I obtain this error? I copy all my code so you can read it. _Thanks a lot
Dim conn As ADODB.Connection
Dim grs As ADODB.Recordset
Private Sub aceptar_Click()
grs.AddNew
grs.Fields("apeusu"
= apeusu.Text
grs.Fields("nomusu"
= nomusu.Text
grs.Fields("clausu"
= clausu.Text
grs.Update
End Sub
Private Sub cancelar_Click()
Unload Me
End Sub
Private Sub Form_Load()
'On Error Resume Next
Set gconn = New ADODB.Connection
gconn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & _
"\data\agenda.mdb"
gsql = "select * from users"
Set grs = New ADODB.Recordset
grs.Open gsql, gconn, adOpenKeyset, adLockOptimistic
'Fin comunicacion con la BD
End Sub
Private Sub Form_Unload(Cancel As Integer)
'cierro la tabla
grs.ActiveConnection = Nothing
gconn.Close
End Sub
Dim conn As ADODB.Connection
Dim grs As ADODB.Recordset
Private Sub aceptar_Click()
grs.AddNew
grs.Fields("apeusu"
grs.Fields("nomusu"
grs.Fields("clausu"
grs.Update
End Sub
Private Sub cancelar_Click()
Unload Me
End Sub
Private Sub Form_Load()
'On Error Resume Next
Set gconn = New ADODB.Connection
gconn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & _
"\data\agenda.mdb"
gsql = "select * from users"
Set grs = New ADODB.Recordset
grs.Open gsql, gconn, adOpenKeyset, adLockOptimistic
'Fin comunicacion con la BD
End Sub
Private Sub Form_Unload(Cancel As Integer)
'cierro la tabla
grs.ActiveConnection = Nothing
gconn.Close
End Sub