Re: Advanced Login Controls - Can you help?
- From: "DubboPete" <osnabruc@xxxxxxxxxxxxxxxxx>
- Date: Mon, 26 Feb 2007 22:02:30 +1100
Hello Mr Access to Access,
I have this solution in code in a database at work, but won't be there for
eight hours....
I have also added the option to do the 'forgot password?' thing too!
So, if you don't get an answer within that time, I shall send you the code
that I use...
DubboPete
"Access To Access" <AccessToAccess@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:73911C24-2865-44AC-818E-C455E2AA343B@xxxxxxxxxxxxxxxx
Thank you for taking the time to read my post regardless of whether you
can
help or not.
I am trying to set up a user control form which will allow users to access
the application but only with the right registered password per user. Each
user has there own password, i am aware of how to set up controls and so
on
for this and have created the code to make this work.
However there is a few enhancements i'd love to add.
1. Allows users only 3 attemps to try and login before the application
closes.
2. As the user makes and error (enters the wrong password) a warning
mesage
box appears telling them how many attempts they have left (each error
means a
message box which counts down the number of attempts left)
I have tried to do "Loops" and "Do" btu am still a novice to vba.
Please find my code below as follows.
Private Sub btnLoginOk_Click()
If IsNull(txtUserName) Or txtUserName.Value = "" Then
MsgBox "Please enter your user name.", vbQuestion + vbOKOnly, "Campaign
Manager"
Exit Sub
End If
If IsNull(txtPassword) Or txtPassword.Value = "" Then
MsgBox "Please enter your password.", vbQuestion + vbOKOnly, "Campaign
Manager"
Exit Sub
End If
If DCount("[username]", "[tblUsers]", "[username]=txtUsername.Value") = 1
Then
currentuser = txtUserName.Value
If txtPassword = DLookup("[password]", "[tblUsers]",
"[username]=txtUsername.Value") Then
If DLookup("[inactive]", "[tblUsers]",
"[username]=txtUsername.Value") = True Then
MsgBox "Your account has been locked. Please contact the
administrator.", vbCritical + vbOKOnly, "Campaign Manager"
Else
DoCmd.OpenForm "frmMain"
With Application.Forms.frmMain.lblusernamewelcome
.Caption = "Welcome! " & UCase(Left(currentuser, 1)) &
Mid(currentuser, 2, 30)
End With
DoCmd.Close acForm, "frmLogin"
End If
Else
MsgBox "Password Incorrect! Please Try Again...", vbCritical +
vbOKOnly,
"Campaign Manager"
End If
Else
MsgBox "The specified user name does not exist!", vbExclamation +
vbOKOnly,
"Campaign Manager"
End If
End Sub
.
- References:
- Advanced Login Controls - Can you help?
- From: Access To Access
- Advanced Login Controls - Can you help?
- Prev by Date: Re: Access 97 - Sending an Email with Content using a Command ***
- Next by Date: Re: Adding item in listbox
- Previous by thread: Advanced Login Controls - Can you help?
- Next by thread: Re: Advanced Login Controls - Can you help?
- Index(es):