473,395 Members | 1,348 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,395 software developers and data experts.

Login Name and Password to Open Form level users.

19
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

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("EmpPassword", "tblAdmins", "[EmpID]=" & Me.cboEmployee.Value) Then

lngMyEmpID = Me.cboEmployee.Value

'Close logon form and open splash screen

DoCmd.Close acForm, "Logon", acSaveNo
DoCmd.OpenForm "MRB"
DoCmd.Maximize

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 your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If

End Sub
Mar 27 '08 #1
8 6234
Dököll
2,364 Expert 2GB
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdLogin_Click()
  3.  
  4. 'Check to see if data is entered into the UserName combo box
  5.  
  6.     If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
  7.             MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
  8.             Me.cboEmployee.SetFocus
  9.         Exit Sub
  10.     End If
  11.  
  12. 'Check to see if data is entered into the password box
  13.  
  14.     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  15.             MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
  16.             Me.txtPassword.SetFocus
  17.         Exit Sub
  18.     End If
  19.  
  20. 'Check value of password in tblEmployees to see if this matches value chosen in combo box
  21.  
  22.     If Me.txtPassword.Value = DLookup("EmpPassword", "tblAdmins", "[EmpID]=" & Me.cboEmployee.Value) Then
  23.  
  24.         lngMyEmpID = Me.cboEmployee.Value
  25.  
  26. 'Close logon form and open splash screen
  27.  
  28.         DoCmd.Close acForm, "Logon", acSaveNo
  29.         DoCmd.OpenForm "MRB"
  30.         DoCmd.Maximize
  31.  
  32.         Else
  33.         MsgBox "Password Invalid.  Please Try Again", vbOKOnly, "Invalid Entry!"
  34.         Me.txtPassword.SetFocus
  35.     End If
  36.  
  37. 'If User Enters incorrect password 3 times database will shutdown
  38.  
  39.     intLogonAttempts = intLogonAttempts + 1
  40.     If intLogonAttempts > 3 Then
  41.         MsgBox "You do not have access to this database.  Please contact your system administrator.", vbCritical, "Restricted Access!"
  42.         Application.Quit
  43.     End If
  44.  
  45. End Sub
Hello!

It looks like your code should work. I will attempt to take a stab a it...

On your form

(1) You'll need a command button named cmdLogin
(2) You'll need one textbox named txtPassword
(3) You'll also need a combobox named cboEmployee

In your table, named tblAdmins

(1) You'll need a field named EmpID (links to nothing on form)
(2) You'll need a field named Employee (links to txtPassword on form)
(3) You'll need a field named EmpPassword (links to cboEmployee on form)

Please stay tuned for more, I could have missed something.

Good luck with project:-)

Dököll
Mar 28 '08 #2
Mai Le
19
Hello!

It looks like your code should work. I will attempt to take a stab a it...

On your form

(1) You'll need a command button named cmdLogin
(2) You'll need one textbox named txtPassword
(3) You'll also need a combobox named cboEmployee

In your table, named tblAdmins

(1) You'll need a field named EmpID (links to nothing on form)
(2) You'll need a field named Employee (links to txtPassword on form)
(3) You'll need a field named EmpPassword (links to cboEmployee on form)

Please stay tuned for more, I could have missed something.

Good luck with project:-)

Dököll

Thank you very much for reply quickly.
My program is working, I would like to enhance it. Let me explain exact what I want to do again.
I would like to modify code above. If Admin login will open MRB form and If User login will open TEST form. That is my idea, I tried some way but did not work. Please give me some help for my project. Thanks again.
Mar 28 '08 #3
Mai Le
19
Thank you very much for reply quickly.
My program is working, I would like to enhance it. Let me explain exact what I want to do again.
I would like to modify code above. If Admin login will open MRB form and If User login will open TEST form. That is my idea, I tried some way but did not work. Please give me some help for my project. Thanks again.


Hello,
I had code below, and did not know how to make it work with Login code.
Please help. Thanks

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("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 "MRB"
Else
If strAccessLevel = "User" Then
DoCmd.OpenForm "TEST"
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
Mar 28 '08 #4
Dököll
2,364 Expert 2GB
Hello,
I had code below, and did not know how to make it work with Login code.
Please help. Thanks
Expand|Select|Wrap|Line Numbers
  1.  Private Sub cmdLogin_Click()
  2.   'Check to see if data is entered into the UserName combo box
  3.  
  4.   If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
  5.   MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
  6.   Me.cboEmployee.SetFocus
  7.   Exit Sub
  8.   End If
  9.  
  10.  'Check to see if data is entered into the password box
  11.  
  12.  If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  13.  MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
  14.  Me.txtPassword.SetFocus
  15.  Exit Sub
  16.  End If
  17.  
  18.  'Check value of password in tblEmployees to see if this matches value chosen in combo box
  19.  
  20.  If Me.txtPassword.Value = DLookup("EmpPassword", "tblAdmins", "[EmpID]=" & Me.cboEmployee.Value) Then
  21.  
  22.  lngMyEmpID = Me.cboEmployee.Value
  23.  End If
  24.  
  25.  
  26.  'Open correct form
  27.  Dim strAccessLevel As String
  28.  
  29.  strAccessLevel = DLookup("[Access]", "tblAdmins", "[EmpID]=" & Me.cboEmployee.Value)
  30.  
  31.  If strAccessLevel = "Admin" Then
  32.  DoCmd.OpenForm "MRB"
  33.  Else
  34.  If strAccessLevel = "User" Then
  35.  DoCmd.OpenForm "TEST"
  36.  Else
  37.  MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
  38.  Me.txtPassword.SetFocus
  39.  Exit Sub
  40.  End If
  41.  End If
  42.  
  43.  'If User Enters incorrect password 3 times database will shutdown
  44.  
  45.  intLogonAttempts = intLogonAttempts + 1
  46.  If intLogonAttempts > 3 Then
  47.  MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
  48.  Application.Quit
  49.  End If
  50.  End Sub
Greetings and salutations Mai Le!

Hope your week-end plans are in order...

I added some code tags for ya for readibility. Loooks like I switched some things around on you, Mai Le:

(1) You'll need a field named EmpID (links to nothing on form)
(2) You'll need a field named EmpPassword (links to txtPassword on form)
(3) You'll need a field named Employee (links to cboEmployee on form)

Did you try this option? Works on my machine:-) I should perhaps mention I did figure out that EmpID is linked to the form's lngMyEmpID field if that helps...

Do you have a table with the fields mentioned. Tell us and we shall continue, no problem.

In a bit!

Dököll
Mar 29 '08 #5
Mai Le
19
Greetings and salutations Mai Le!

Hope your week-end plans are in order...

I added some code tags for ya for readibility. Loooks like I switched some things around on you, Mai Le:

(1) You'll need a field named EmpID (links to nothing on form)
(2) You'll need a field named EmpPassword (links to txtPassword on form)
(3) You'll need a field named Employee (links to cboEmployee on form)

Did you try this option? Works on my machine:-) I should perhaps mention I did figure out that EmpID is linked to the form's lngMyEmpID field if that helps...

Do you have a table with the fields mentioned. Tell us and we shall continue, no problem.

In a bit!

Dököll

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.
Mar 29 '08 #6
Scott Price
1,384 Expert 1GB
Mai Le,

I have already warned you once to not double post. I see that this is the first thread you posted about this exact same question. Here is a link to the duplicate posting.

Double posting consumes resources and causes confusion. If it happens again it will result in a temporary ban of 1 week.

MODERATOR
Mar 29 '08 #7
Mai Le
19
Mai Le,

I have already warned you once to not double post. I see that this is the first thread you posted about this exact same question. Here is a link to the duplicate posting.

Double posting consumes resources and causes confusion. If it happens again it will result in a temporary ban of 1 week.

MODERATOR
Hi Scott,
Sorry for confusing, I'm still new in this forum. I tried to learn and understand in urgent. Please ignore this post and delete it if needed. Thanks for your help. You are greatly help. Your code is working in my program. Thank you very much!!
That took me a week to think and figure out how it work. I took your code and applied to my program. It's wonderful.

Mai Le
Mar 29 '08 #8
Scott Price
1,384 Expert 1GB
No problem, Mai Le I understand that things can be confusing.

Glad the code is working for you!

Good luck on the rest of your application.

Regards,
Scott
Mar 29 '08 #9

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

Similar topics

1
by: Wayne Smith | last post by:
Applies to: Microsoft FrontPage 2000, Microsoft Access 2000, IIS 5.0 Operating System: Microsoft Windows 2000 Professional I am trying to protect a portion of a web site by allowing users to...
5
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...
1
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...
7
by: Cemal Karademir | last post by:
Hi, I'm workin on a small Login page/program with asp.net. It uses an MS-Access database that looks like this: USERID | NAME | PASSWORD _________________________________ 1 ...
9
by: dana lees | last post by:
Hello, I am developing a C# asp.net application. I am using the authentication and authorization mechanism, which its timeout is set to 60 minutes. My application consists of 2 frames - a...
1
by: jsd219 | last post by:
I have a fairly simple login in script and I need to make it have two levels of access not one. can anyone help me with this? The script is below: <?php // we must never forget to start the...
3
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...
3
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...
3
by: satishknight | last post by:
Hi, Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it...
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: 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...
0
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
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 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.