Option Explicit
Const cadena = "provider=microsoft.jet.oledb.4.0;data source=agenda2.mdb"
Dim cnn As ADODB.Connection
Dim rscomand As ADODB.Command
Private Sub cmdbuscar_Click()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim comand As ADODB.Command
Dim x, strsql As String
Set rs = New ADODB.Recordset
If cmdbuscar.Value = True Then
x = InputBox("introduce el nombre a buscar", "ingresar el nombre")
If x <> "" Then
Dim intreg
Set cnn = New ADODB.Connection
cnn.Open cadena
Set comand = New ADODB.Command
Set comand.ActiveConnection = cnn
comand.CommandText = "select * from tabla0 where nombre like '" + x + "'"
comand.CommandType = adCmdText
comand.Execute intreg
If intreg = 1 Then
MsgBox "se encontro el registro", vbInformation + vbOKOnly, "comando"
Else
MsgBox "el registro no se encontro", vbInformation + vbOKOnly, "comando"
End If
cnn.Close
Set cnn = Nothing
End if
End if
End sub
Private Sub cmdguardar_Click()
Dim intreg
Set cnn = New ADODB.Connection
cnn.Open cadena
Set rscomand = New ADODB.Command
Set rscomand.ActiveConnection = cnn
If txtnombre.Text = "" Or _
txtcalle.Text = "" Then
MsgBox "datos incompletos", vbCritical, "error"
Exit Sub
End If
rscomand.CommandText = "insert into tabla0(nombres,calles)values('" & txtnombre.Text & "','" & txtcalle.Text & "')"
rscomand.CommandType = adCmdText
rscomand.Execute intreg
If intreg = 1 Then
MsgBox "se grebo el registro", vbInformation + vbOKOnly, "comando"
Else
MsgBox "el registro no se grabo", vbInformation + vbOKOnly, "coamndo"
End If
cnn.Close
Set cnn = Nothing
End Sub
Ademas me sale un error k dic “variable de tipo object o la variable