Código:
Option Explicit Private Sub Command1_Click() 'Recuerda destruir las direcciones de la memoria... nc.Close Set nc = Nothing End End Sub Private Sub Command2_Click() If Trim(Combo1.Text) = "" Then MsgBox "Seleccione el nombre de usuarios", 16, "Para Ingresar al sistema" Combo1.SetFocus Exit Sub End If If Trim(Clave.Text) = "" Then MsgBox "Ingrese su clave de acceso", 16, "Para ingresar al sistema" Clave.SetFocus Exit Sub End If Ingresar_Clave End Sub Private Sub Form_Load() Iniciar_Conexion Cargar_Usuarios End Sub Private Sub Iniciar_Conexion() Dim sPath As String sPath = App.Path & "\sg1.mdb" With nc .Provider = "Microsoft.Jet.OLEDB.4.0" .Properties("Data Source").Value = sPath .Properties("Persist Security Info").Value = False .Open End With End Sub Private Sub Cargar_Usuarios() Dim rs As New ADODB.Recordset rs.Open "SELECT * FROM usuarios", nc, adOpenDynamic, adLockOptimistic While Not rs.EOF Combo1.AddItem rs!Nombre rs.MoveNext Wend rs.Close Set rs = Nothing End Sub Private Sub Ingresar_Clave() Dim rec As New ADODB.Recordset Dim clav As String Dim EstM As Boolean rec.Open "SELECT * FROM usuarios where Clave='" & Trim(Clave.Text) & "'", nc, adOpenStatic, adLockOptimistic, adCmdText With rec If .RecordCount > 0 Then clav = Trim(.Fields("Clave")) If clav = Trim(Clave.Text) Then MsgBox "Bievenido a Archivos del Sistema" & Space(2) & Combo1.Text, vbInformation, "Bienvenido al Sistema" Unload Me EstM = True MDIForm1.Show Else MsgBox "Clave Incorrecta", vbInformation, "Aviso..!!" Clave = "" Clave.SetFocus End If End If End With rec.Close Set rec = Nothing End Sub