Hello Experts.
Coul you please help me to fix my program.
I created a login from with 2 levels. Admin an User.
If Admin login will open A form
and If User login will open B form
I had table tblAdmins
EmpID
EmpName
EmpPassword
Access field for Admin and User Level
Here is the code - 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 tblAdmins to see if this matches value chosen in combo box
-
-
If Me.txtPassword.Value = DLookup("EmpPassword", "tblAdmins", "[EmpID]=" & Me.cboEmployee.Value) Then
-
-
lngMyEmpID = Me.cboEmployee.Value
-
End If
-
-
-
'Open correct form
-
Dim strAccessLevel As String
-
-
strAccessLevel = DLookup("[Access]", "tblAdmins", "[EmpID]=" & Me.cboEmployee.Value)
-
-
If strAccessLevel = "Admin" Then
-
DoCmd.OpenForm "A"
-
Else
-
If strAccessLevel = "User" Then
-
DoCmd.OpenForm "B"
-
Else
-
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
-
Me.txtPassword.SetFocus
-
Exit Sub
-
End If
-
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
-
I tried but could not. Please help.
Thanks in advance
5 3677
Mai Le,
Please do not double post. I have deleted your other thread relating to this same question but without the added code.
Please use the [code] tags provided by selecting your code text in this reply window and clicking the # icon on the menu bar of the reply window.
MODERATOR
What is the problem that you are facing with this code? You need to tell us what doesn't work.
Regards,
Scott
What is the problem that you are facing with this code? You need to tell us what doesn't work.
Regards,
Scott
Thanks for your support.
The code is working but somehow put any password in then can open form. another is password stays in password.
Please help again.
Thanks
Have a nice weekend.
Your code looks a little choppy. By this I mean that it doesn't flow correctly from one procedure to the next. Try this: - Private Sub cmdLogin_Click()
-
-
'Check to see if data is entered into the UserName combo box
-
Dim lngMyEmpID As Long
-
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
-
lngMyEmpID = Me.cboEmployee.Value
-
'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 tblAdmins to see if this matches value chosen in combo box
-
-
If Me.txtPassword.Value <> DLookup("EmpPassword", "tblAdmins", "[EmpID]=" & lngMyEmpID) Then
-
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
-
Me.txtPassword.SetFocus
-
Me.txtPassword = Null
-
intLogonAttempts = intLogonAttempts + 1
-
'If User Enters incorrect password 3 times database will shutdown
-
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
-
-
Else
-
Me.txtPassword = Null
-
'Open correct form
-
Dim strAccessLevel As String
-
-
strAccessLevel = DLookup("[Admins]", "tblAdmins", "[EmpID]=" & lngMyEmpID)
-
-
If strAccessLevel = "Admin" Then
-
MsgBox "Welcome " & DLookup("EmpName", "tblAdmins", "EmpID=" & lngMyEmpID)
-
DoCmd.Close
-
DoCmd.OpenForm "A"
-
ElseIf strAccessLevel = "User" Then
-
MsgBox "Welcome " & DLookup("EmpName", "tblAdmins", "EmpID=" & lngMyEmpID)
-
DoCmd.Close
-
DoCmd.OpenForm "B"
-
End If
-
End If
-
-
End Sub
Regards,
Scott
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Phillip Armitage |
last post by:
I've spent the better part of two days checking out PHP, javascript and
numerous other language sites trying to find what I figure should be be an
easy web script page. Essentially what I want is a...
|
by: william cline |
last post by:
Hi, I am a beginner and below I have code for a long in form. My goal is
for the form to read a file of a list of users and thier passwords
....compare the text box inputs to the file and either...
|
by: Jack Addington |
last post by:
I've got a fairly simple application implementation that over time is going
to get a lot bigger. I'm really trying to implement it in a way that will
facilitate the growth. I am first writing a...
|
by: David Krussow |
last post by:
Just wondering if/how it would be possible to display a variable string on
the login form - where the string varies depending on the form the user
attempted to access.
To clarify, an...
|
by: Jennifer.Berube |
last post by:
okay...so I got this login script and I edited it all and it seems to
run fine...IE it listens to the script as far as permissions go when I
place a restriction on a page and when you login it...
|
by: luqman |
last post by:
If user login with the login control in ASP.Net 2005 and then just close the
browser and then open the browser again, the login status shows, User still
Login?
Any idea, how to Logout the User...
|
by: stumo |
last post by:
Hi
I'm fairly new to access and as such my experience of VBA is somewhat limited. I have a login form which is linked to an "employees table" which asks for users to enter their name and...
|
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= |
last post by:
I get the above error in some of the ASP.NET web applications on a
server, and I need some help figuring out how to deal with it.
This is a rather long post, and I hope I have enough details that...
|
by: Mai Le |
last post by:
Hello,
I used Microsoft Access to create a login form with
Name
Password
Access Level Admin and User
I would like to let Admin login and open MRB form and User login then open other form like...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |