Please help me how will i solve my problem with login. The requirement is to terminate/lock the system, if after 3 attempts, the user failed to entered a right password. I used a some codes (indicated below). When i enter a correct username & password, it shows the next form. Here's the problem, when i try to enter an incorrect password, it doesnt lock. what it does, it overwrites the saved password on the database (access) and it still enters the next form. :-| ALSO, if i enter an incorrect username and password, here's the error:

Run-time error '-2147217887 (80040e21)':
Multiple-step operation generated errors. Check each status value.

PLEASE HELP ME!! I have no other sources. Only this site!!


In advance, Thanks for your reply!!


Here's the code i used:

Private Sub cmdOK_Click()

With Adodc1
.Recordset.Find "username ='" & txtUserName.Text & "'"
.Recordset.Find "password = '" & txtPassword.Text & "'"
If Adodc1.Recordset.EOF Then
MsgBox "Invalid Password and Username, try again!", vbOKOnly + vbInformation, "Admin"
Label1.Caption = Val(Label1.Caption) + 1
txtUserName.Text = ""
txtPassword.Text = ""
txtUserName.SetFocus
If Label1.Caption = 2 Then
MsgBox "This is now your last attempt, try again!", vbOKOnly + vbCritical, "Warning"
ElseIf Label1.Caption = 3 Then
MsgBox "System Locked", vbCritical, "System Administrator"
frmLogin.Enabled = False
End If
Else
LMPMain.Show
Unload Me
End If
End With
End Sub


Respectfully,
purplestar86

'i have an idea, you can use it if you want, you dont have to, but 'here it is,

'create a module, doesnt matter what its called and add this code:

'beginning of code

Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Function ReadINI(Section As String, KeyName As String, FileName As String) As String
Dim sRet As String
sRet = String(255, Chr(0))
ReadINI = Left(sRet, GetPrivateProfileString(Section, ByVal KeyName$, "", sRet, Len(sRet), FileName))
End Function

Sub WriteINI(sSection As String, sKeyName As String, sNewString As String, sFilename)
Call WritePrivateProfileString(sSection, sKeyName, sNewString, sFilename)
End Sub

'end of code

'then in your main form put this code:

'beginning of code
dim ini_path as string

private sub cmdok_click()
ini_path="c:/program files/bang.ini" 'doesnt have to be ini, can be any format

if txtusername.text=readini("setting","username",ini_path) then
if txtpassword.text= readini("setting","password",ini_path) then
msgbox"login successful"
'your own actions
else
msgbox"error"
endif
else
msgbox"error"
endif
end sub

'end of code

'and for changin usernames or password use this code:

'beginning of code

private sub cmdnew_click()
ini_path="c:/program files/bang.ini"
call writeini("setting","username",txtusername.text,ini_path)
call writeini("setting","password",txtpassword.text,ini_path
end sub
'and there you are, happy programming...

Please help me how will i solve my problem with login. The requirement is to terminate/lock the system, if after 3 attempts, the user failed to entered a right password. I used a some codes (indicated below). When i enter a correct username & password, it shows the next form. Here's the problem, when i try to enter an incorrect password, it doesnt lock. what it does, it overwrites the saved password on the database (access) and it still enters the next form. :-| ALSO, if i enter an incorrect username and password, here's the error:

Run-time error '-2147217887 (80040e21)':
Multiple-step operation generated errors. Check each status value.

PLEASE HELP ME!! I have no other sources. Only this site!!


In advance, Thanks for your reply!!


Here's the code i used:

Private Sub cmdOK_Click()

With Adodc1
.Recordset.Find "username ='" & txtUserName.Text & "'"
.Recordset.Find "password = '" & txtPassword.Text & "'"
If Adodc1.Recordset.EOF Then
MsgBox "Invalid Password and Username, try again!", vbOKOnly + vbInformation, "Admin"
Label1.Caption = Val(Label1.Caption) + 1
txtUserName.Text = ""
txtPassword.Text = ""
txtUserName.SetFocus
If Label1.Caption = 2 Then
MsgBox "This is now your last attempt, try again!", vbOKOnly + vbCritical, "Warning"
ElseIf Label1.Caption = 3 Then
MsgBox "System Locked", vbCritical, "System Administrator"
frmLogin.Enabled = False
End If
Else
LMPMain.Show
Unload Me
End If
End With
End Sub


Respectfully,
purplestar86

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.