By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,473 Members | 3,234 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,473 IT Pros & Developers. It's quick & easy.

Login former in in access 07

P: 39
Hi friends.
I created login form in access 07 with via code but something wrong with code.
Actually every passwords from tbluser matchs to any usernames.means when I enter username of users and password any users or 2 or 3 is to it.
I can't find what is wrong in code.And one more thing application quite when user attempt more than 3 unsuccessful login attempts. I use following code.please help mensure. Option Compare Database
Option Explicit

Private Sub Command1_Click()
Dim User As String
Dim Userlevel As Integer
Dim Temppass As String
Dim ID As Integer
Dim UserName As String
Dim TempLoginID As String
Dim intlogonattempts As Integer
If IsNull(Me.TxtUsername) Then
MsgBox "Please enter UserName", vbInformation, "Username Requeired"
Me.TxtUsername.SetFocus
ElseIf IsNull(Me.TxtPassword) Then
MsgBox "Please enter Password", vbInformation, "Password Requeired"
Me.TxtPassword.SetFocus
Else
If IsNull(DLookup("UserLogin", "tblUser", "UserLogin='" & Me.TxtUsername.Value & "'")) Then
MsgBox "Invalid UserName"
Me.TxtUsername.SetFocus
ElseIf IsNull(DLookup("Password", "tblUser", "PassWord ='" & Me.TxtPassword.Value & "'")) Then
MsgBox "Invalid PassWord.Please Try Again", vbOKOnly, "Invalid Password"
Me.TxtPassword.SetFocus

Else
TempLoginID = Me.TxtUsername.Value
UserName = DLookup("[UserName]", "tblUser", "[UserLogin]= '" & Me.TxtUsername.Value & "'")
Userlevel = DLookup("[UserSecurity]", "tblUser", "[UserLogin]='" & Me.TxtUsername.Value & "'")
Temppass = DLookup("[Password]", "tblUser", "[UserLogin]='" & Me.TxtUsername.Value & "'")
ID = DLookup("[UserID]", "tblUser", "[UserLogin]='" & Me.TxtUsername.Value & "'")
DoCmd.Close
If Userlevel = 1 Then
DoCmd.OpenForm "Main Form"
Forms![Main Form]![TxtLogin] = UserName
Else
DoCmd.OpenForm "Main Form"
Forms![Main Form]![TxtLogin] = UserName
Forms![Main Form]!CmdAdmin.Enabled = False
End If
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 If
End If




End Sub

Private Sub Form_Load()
Me.TxtUsername.SetFocus
End Sub
Mar 26 '17 #1

✓ answered by MikeTheBike

Hi

ry replacing This
Expand|Select|Wrap|Line Numbers
  1. ElseIf IsNull(DLookup("Password", "tblUser", "PassWord ='" & Me.TxtPassword.Value & "'")) Then
with this
Expand|Select|Wrap|Line Numbers
  1. ElseIf (Me.TxtPassword.Value <> IsNull(DLookup("Password", "tblUser",  "[UserLogin]='" & Me.TxtUsername.Value & "'"))) Or Len(Me.TxtPassword.Value) = 0 Then
In short you need to compare the User's password to the Password entered by the user, not the Password's password!!!


HTH

MTB

Share this Question
Share on Google+
6 Replies


Expert 100+
P: 634
Hi

ry replacing This
Expand|Select|Wrap|Line Numbers
  1. ElseIf IsNull(DLookup("Password", "tblUser", "PassWord ='" & Me.TxtPassword.Value & "'")) Then
with this
Expand|Select|Wrap|Line Numbers
  1. ElseIf (Me.TxtPassword.Value <> IsNull(DLookup("Password", "tblUser",  "[UserLogin]='" & Me.TxtUsername.Value & "'"))) Or Len(Me.TxtPassword.Value) = 0 Then
In short you need to compare the User's password to the Password entered by the user, not the Password's password!!!


HTH

MTB
Mar 27 '17 #2

P: 39
Thank you so much Mike.I will try this.
Mar 27 '17 #3

P: 39
Mike .. I try your solution but it till not work.by replacing line you suggest no one of the password from list is match .and what about application quite after 3unsuccessful attempts
Mar 29 '17 #4

P: 5
Have a look on this for creating a login form. Full script is provided in this which will help you to figure out the mistake you are doing. Have a look:http://www.databasedev.co.uk/login.html
Mar 30 '17 #5

P: 39
Thankz Stephen08.
But i want to txtbox for username than cmbbox becouze there are many users of my db.so please any solution for txtbox.
Mar 30 '17 #6

P: 39
Can any one helps me to solve this issue please.
Apr 4 '17 #7

Post your reply

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