Hello,
I am new to Access and I have created a database for my company. I found code for a login script online. The code I used is as follows. - 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 splash screen
-
-
DoCmd.Close acForm, "frmLogon", acSaveNo
-
DoCmd.OpenForm "frmSplash_Screen"
-
-
-
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
I have created a Table called tblEmployees with the FIELDS of EmpID, EmpName, EmpPassword, and EmpUsertype. For the Usertype FIELD I inputted Admin or User for each person in the company. I need to have any user with Admin to be able to open a form that is specifically for admins, which I called frmSplash_Screen_Admin. Is there any way I could add to the existing code above? If not could anyone help me figure out how to do solve this issue?
Thank you.
3 6091 NeoPa 32,556
Expert Mod 16PB
Your data doesn't seem to match the code at all. The field names are different. You need to go through the code first to make sure it matches your names for all the objects (fields etc).
When that's completed, in place of line #30 put the following lines : -
If DLookup("[EmpUserType]", _
-
"[tblEmployees]", _
-
"[EmpID]=" & Me.cboEmployee) = "Admin" Then
-
-
DoCmd.OpenForm "frmSplash_Screen_Admin"
-
Else
-
DoCmd.OpenForm "frmSplash_Screen"
-
End If
Welcome to Bytes!
Hello NeoPa,
I actually didn't notice that I didn't match the Field names on the code with my tables. Your advice worked perfectly for me. Thank you very much.
NeoPa 32,556
Expert Mod 16PB
Very pleased to hear it.
Good luck with your project.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: cpajoe2001 |
last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help.
What i have is ServerA...
|
by: nebbiasun |
last post by:
I have a split database which calls a word document (mail merge from
query) which works perfectly in both access 2003 and 2007. I have
secured the frontend and backend (user level security) in 2003...
|
by: SilentThunderer |
last post by:
Hey folks,
Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
|
by: ajos |
last post by:
hi frnds,
im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception.
to verify this error ive...
|
by: Alfred |
last post by:
Hi
In Access 2007 (the MDE) The taskbar displays Powered by Microsoft Access.
How can I remove it
Thanks
Alfred
|
by: jxt1303 |
last post by:
I've created an Access 2007 application that has linked tables in a SharePoint 2007 site. Normally, after I open the app and access a form that uses one of these linked tables, you are prompted for...
|
by: tbeers |
last post by:
Good morning.
I have an interesting chain of events.
My 2007 program has been working fine on a network. I have a split database with tables on F:\timekeeper and front end on terminal server...
|
by: gbaii |
last post by:
Hi all. Being new to access and wanting to build some kind of basic CRM software, I have the following problem. I have a table called users with the fields: UserID, UserName, UserPass and UserType....
|
by: BL3WC |
last post by:
Hi,
I'd created a MDE under Access 2003. It is now under testing stage. Some of the users will use Access 2003 runtime and some will use Access 2007 runtime to run this MDE. I installed the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: 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: 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,...
|
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...
|
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: 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: 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,...
| |