I would guess that you have a field in the same table where you are
tracking the username and password that identifies the user level.
Dim strUserForm as String
IF strUserForm = DLookup
("strAccessLevel", "tblEmployees", "[txtLevel]=" &
"Level1") Then
docmd.OpenForm "frm1"
Else
msgbox "see the administrator"
End IF
IF strUserForm = DLookup
("strAccessLevel", "tblEmployees", "[txtLevel]=" &
"Level2") Then
docmd.OpenForm "frm2"
Else
msgbox "see the administrator"
End IF
Dawn Crosier
Application Specialist
"Education Lasts a Lifetime"
This message was posted to a newsgroup. Please post replies and
questions to the group so that others can learn as well.
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of martybevo
Sent: Friday, January 20, 2006 12:53 PM
To: [email protected]
Subject: [AccessDevelopers] Trouble adding another condition...
Hi all.
I have a logon form that I'm using within the access database. The form
currently works great... basically, if username and password match then
grant access to form1. If not, then get error message.
Now, I need to add... if username and password match then gpto form1 is
you have access level 1 or form2 if you have access level 2. If not then
get error message.
Here is the code below... I'm unsure on where to place the additional
code and actually what it would look like.
Any help is greatly appreciated.
Thank you.
Domenic
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 Main Menu
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "frmMain"
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
Please zip all files prior to uploading to Files section.
Yahoo! Groups Links
Please zip all files prior to uploading to Files section.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AccessDevelopers/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/