Código:
es un textbox el cual me funciona muy bien, y todo el problema esta que cuando estoy dentro de ese textbox y doy ESC (scape) el textbox se pierde y me sale el mensaje de ingrese un DNI correcto no se que falta o que esta mal en ese codigo, espero su ayuda gracias ;) Private Sub txtdni_LostFocus()
If Len(txtdni.Text) >= 8 Then
Else
MsgBox "Ingrese un DNI Correcto", vbInformation, ""
txtdni.SetFocus
Exit Sub
End If
'txtdni.Visible = False
Dim dni As ADODB.Recordset
Set dni = New ADODB.Recordset
dni.Open "select * from clientes where dni='" & txtdni.Text & "'", db, adOpenDynamic, adLockBatchOptimistic
If dni.EOF Then
'MsgBox "DNI No Existe, Puede Usarlo", vbCritical, "Error"
Else
MsgBox "DNI Ya Existe PorFavor Ingresar Otro", vbCritical, "Error"
txtdni.SetFocus
Exit Sub
End If
End Sub


