Want to create a logon form with username and password from Access Form

Anyone out there have any examples that will help me create a form in Access where a user can enter there username and password to enter the database? I want to capture there username to be used later when creating reports as well..

Thanks in advance!
LVL 2
Jarred MeyerProduction ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
This should get you started:

http://www.databasedev.co.uk/login.html

mx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jarred MeyerProduction ManagerAuthor Commented:
This is exactly what I'm looking for however, I cannot get passed a certain line in the code..

The entire code I'm using is;

Private Sub cmdLogon_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("EmpPassword", "tblEmployees", _
            "[EmpName]=" & Me.cboEmployee.Value) Then

        EmpName = Me.cboEmployee.Value

        'Close logon form and open splash screen

        DoCmd.Close acForm, "frmLogon", acSaveNo
        DoCmd.OpenForm "frmSplash"

    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

End Sub

Open in new window


It errors out at;

   If Me.txtPassword.Value = DLookup("EmpPassword", "tblEmployees", _
            "[EmpName]=" & Me.cboEmployee.Value) Then


And gives me the following error message;

 error
jmeyer is one of the user names..

Any ideas on this?
0
als315Commented:
Try
If Me.txtPassword.Value = DLookup("EmpPassword", "tblEmployees", _
            "[EmpName]='" & Me.cboEmployee.Value & "'") Then
Me.cboEmployee.Value is text field, when in example it is numeric. Add single quote before and after Me.cboEmployee.Value
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"
It errors out at;

   If Me.txtPassword.Value = DLookup("EmpPassword", "tblEmployees", _
            "[EmpName]=" & Me.cboEmployee.Value) Then"

Use this:

   If Me.txtPassword = DLookup("EmpPassword", "tblEmployees",  "[EmpName]=" & Chr(34) & Me.cboEmployee & Chr(34) ) Then
0
Jarred MeyerProduction ManagerAuthor Commented:
als315.. That did the trick!

Thanks DatabaseMX.. That link was exactly what I was looking for!
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
You are welcome.  Shame on that site for having syntax errors ... !

0
Jarred MeyerProduction ManagerAuthor Commented:
Thanks Data.. I just posted another question on this asking how to store the username for later use.. I asked that along with this in the original question but figured it is a good question on its on since it can apply to a lot of different situations aside from just a login screen..

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_27516682.html 
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.