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 3708
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 self calling script (ASP,
PHP, whatever) which will do the following:
Let's assume that my script is called FTP.ASP
1) Display an HTML login form prompting user to enter a user name and
password. Login button action (either at the button or...
|
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 start over or load the
main file.... I attempted to use a slect case..but its not working for me..
If someone has a better way of doing it..I would apperciate the help. Thank
you!
Option Explicit
Public LoginSucceeded As Boolean
|
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 WinForms interface and then
need to port that to a web app. I am kinda stuck on a design issue and need
some suggestions / direction.
Basically I have a business layer that I want to use to process any
dataentry logic (row focus changes, data...
|
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 unauthenticated user is browsing the site, and tries to open
the UltraSecretContent.aspx page. Forms authentication automatically
redirects the user to login.aspx. I would like for login.aspx to display a
message that reads, "You must log in before viewing...
|
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 redirects. But
first it doesn't tell you that you're logged in and doesn't provide a
logout feature.
And most importantly if I type in a random username and password not
listed in the database it doesn't seem to matter it still "lets me
login"
| |
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 when the User click on the Close Button of
Browser ?
I am using Sql Membership Provider for security.
Best Regards,
|
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 password. The current VBA performs all the relevant checks around user name & password etc with no problems. However based on the users access level (which is set in the field "strAccess" in the Enployees table) when I click the "Login" button I'd like to...
|
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
someone who bothers to read all of it have some pointers.
Note, I have posted the stack trace and the code exhibiting the problem
further down so if you want to start by reading that, search for +++
Also note that I am unable to reproduce...
|
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 "test"
Please show me how to do it
Thanks in advance
I had code below
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |