M
Michael Hanlon
listed below is the code i have written that is not working any help would
be great if you can show me where i went wrong as i am new to this side.
thanks in advance.
Private Sub cmdlogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cbousername) Or Me.cbousername = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cbousername.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtpassword) Or Me.txtpassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtpassword.SetFocus
Exit Sub
End If
'Check value of password in usyspassword to see if this
'matches value chosen in combo box
If Me.txtpassword.Value = DLookup("Password", "usyspassword", "[ID]=" &
Me.cbousername.Value) Then
ID = Me.cbousername.Value
'Close logon form and open splash screen
If Me.cbousername.Value = "admin" Then
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 1"
ElseIf passwd = "b" Then
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 2"
ElseIf passwd = "c" Then
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 3"
Else
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 4"
End If
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtpassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
Exit_cmdlogin_Click:
Exit Sub
End Sub
be great if you can show me where i went wrong as i am new to this side.
thanks in advance.
Private Sub cmdlogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cbousername) Or Me.cbousername = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cbousername.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtpassword) Or Me.txtpassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtpassword.SetFocus
Exit Sub
End If
'Check value of password in usyspassword to see if this
'matches value chosen in combo box
If Me.txtpassword.Value = DLookup("Password", "usyspassword", "[ID]=" &
Me.cbousername.Value) Then
ID = Me.cbousername.Value
'Close logon form and open splash screen
If Me.cbousername.Value = "admin" Then
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 1"
ElseIf passwd = "b" Then
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 2"
ElseIf passwd = "c" Then
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 3"
Else
DoCmd.Close
DoCmd.OpenForm "pers", acNormal, , "[group] = 4"
End If
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtpassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
Exit_cmdlogin_Click:
Exit Sub
End Sub