Dim cnx1 As ADODB.Connection
Dim cmd1 As ADODB.Command
Dim rs1 As Recordset
Set cnx1 = New ADODB.Connection
cnx1.CursorLocation = adUseClient
cnx1.Open "Provider=Microsoft Jet 4.0 OLE DB Provider;" _
& "Data Source=C:\Ruta\BaseDeDatos.mdb;"
Set cmd1 = New ADODB.Command
Set cmd1.ActiveConnection = cnx1
cmd1.CommandType = adCmdText
cmd1.CommandText = "SELECT * FROM Contactos " _
& "WHERE UCase(Trim(Nombre))='" _
& UCase(Trim(txtNombre.Text)) & "' AND " _
& "UCase(Trim(Apellidos))='" _
& UCase(Trim(txtApellidos.Text)) & "'"
Set rs1 = cmd1.Execute()
If rs1.RecordCount > 0 Then MsgBox "Ya existe en la tabla"
rs1.Close
Set rs1 = Nothing
Set cmd1 = Nothing
cnx1.Close
Set cnx1 = Nothing