1

Ayuda con este Código

Option Explicit
Dim CN As ADODB.Connection
Dim tbl As Recordset


Private Sub Consulta()

Dim tbl As ADODB.Recordset
 tbl.CursorLocation = adUseClient
 tbl.CursorType = adOpenDynamic
 tbl.LockType = adLockBatchOptimistic
 tbl.Open "Select * from Proveedores where Rif", CN, adOpenDynamic, adLockBatchOptimistic
 Set DataGrid1.DataSource = tbl
End Sub
End Sub

Private Sub agr_Click()  <- El error me lo marca es Aqui "Variable no definida"

Dim tbl As ADODB.Recordset
tbl.Open "Select * from Proveedores where Rif =" & Text1.Text, CN, adOpenDynamic, adLockOptimistic

If tbl.EOF = True And tbl.BOF = True Then
tbl.AddNew
tbl("Rif") = Tex1.Tex
tbl("Cod_Proveedor") = Tex2.Tex
tbl("Nombre del proveedor") = Tex3.Tex
tbl("Dirección") = Tex4.Tex
tbl("Tipo de persona") = Text5.Text
tbl("Corre electrónico") = Tex6.Text
tbl("Telefóno") = Text7.Text
tbl.Update

Else
MsgBox "El registro ya existe", vbCritical, "Error"
End If
End Sub
End Sub


No  entiendo que me falta para que no me de error, si no es ese es variable de objeto, soy novato en esto. Disculpen solo quiero un poco de ayuda, gracias

Escribe tu comentario
+ 2