473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Access 2007 Login help

10
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.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdLogin_Click()
  2.  
  3. 'Check to see if data is entered into the UserName combo box
  4.  
  5.     If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
  6.       MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
  7.         Me.cboEmployee.SetFocus
  8.         Exit Sub
  9.     End If
  10.  
  11.     'Check to see if data is entered into the password box
  12.  
  13.     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  14.       MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
  15.         Me.txtPassword.SetFocus
  16.         Exit Sub
  17.     End If
  18.  
  19.     'Check value of password in tblEmployees to see if this
  20.     'matches value chosen in combo box
  21.  
  22.     If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
  23.             "[lngEmpID]=" & Me.cboEmployee.Value) Then
  24.  
  25.         lngMyEmpID = Me.cboEmployee.Value
  26.  
  27.         'Close logon form and open splash screen
  28.  
  29.         DoCmd.Close acForm, "frmLogon", acSaveNo
  30.         DoCmd.OpenForm "frmSplash_Screen"
  31.  
  32.  
  33.     Else
  34.       MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
  35.             "Invalid Entry!"
  36.         Me.txtPassword.SetFocus
  37.     End If
  38.  
  39.     'If User Enters incorrect password 3 times database will shutdown
  40.  
  41.     intLogonAttempts = intLogonAttempts + 1
  42.     If intLogonAttempts > 3 Then
  43.       MsgBox "You do not have access to this database.Please contact admin.", _
  44.                vbCritical, "Restricted Access!"
  45.         Application.Quit
  46.     End If
  47.  
  48. 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.
Apr 15 '09 #1
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 :
Expand|Select|Wrap|Line Numbers
  1.         If DLookup("[EmpUserType]", _
  2.                    "[tblEmployees]", _
  3.                    "[EmpID]=" & Me.cboEmployee) = "Admin" Then
  4.  
  5.             DoCmd.OpenForm "frmSplash_Screen_Admin"
  6.         Else
  7.             DoCmd.OpenForm "frmSplash_Screen"
  8.         End If
Welcome to Bytes!
Apr 15 '09 #2
menkenk
10
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.
Apr 15 '09 #3
NeoPa
32,556 Expert Mod 16PB
Very pleased to hear it.

Good luck with your project.
Apr 15 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
0
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...
4
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...
8
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...
7
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
0
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...
1
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...
6
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....
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
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...
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.