Problems With Code For Login. Please Help

bogushs

Registered User.
Local time
Today, 11:43
Joined
May 4, 2005
Messages
27
Hi there

Im having a few problems trying to get my login form to function properly. I have created a username and login form.
- created 2 unbound text boxes with user and password
- created a button that performs the function of calling the username and password based on whether the user enters the password correctly.

When you input the password it continue to prompt you to enter the password when it is the correct password.

Does anyone know how to get around this?

Thanks
database attached + code for command below

Private Sub cmdLogin_Click()

'Check to see if data is entered into the UserName combo box

If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.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 tblEmployees to see if this matches value chosen in combo box

If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then

lngMyEmpID = Me.cboEmployee.Value

'Close logon form and open frm Load

DoCmd.Close acForm, "frm Test", acSaveNo
DoCmd.OpenForm "frm Load"

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 your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub
 
Problem with Code For Login

Here is a sample database with the code that I use to make my work.
 

Attachments

hi there.

thanks for replying. im using the same code however the problem im having is that when i include a gif button to act in the same way as the normal default raised buttons in access the control does not work.

do you know a way around this?

cheers
 
Re: Problem With Code For Login

You are correct I had never tried it with a gif image. The code will not work with an image file type. About the only was I can see that we be quick and simple would be to convert your gif to a bmp and add the image to the button. It will fill the entire button with the image. See if that will work for you, at least for now anyways. :cool:
 
great suggestion! where are the access bmp files stored? i cant seem to find them.

cheers
 
if you create the standard button and go into the properties of the button the third item on the all properties tab should be "picture" click on there and you will get a pop up that will allow you to selct an image or clcik on browes and you can navigate to your own bmp file and select it. Thats the way that I would do it if it was me. :D Hope that helps
 

Users who are viewing this thread

Back
Top Bottom