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 3684
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: 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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |