Hi All,
I have a problem on a username password login form. I use:
txtPassword.Tex t = StrConv(txtPass word.Text, vbProperCase) to validate the
proper case when someone enters their name and password. It work when you
use the button to continue, but if you hit enter on your keyboard the event
apparently doesnt lose focus and it says you entered the wrong password. Is
there an easy fix for this. I pointed out the problem code below. Any help
would be appreciated.
Thanks,
Kelsey
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click ()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim db As Database
Dim rs As DAO.Recordset
Set db = OpenDatabase(Ap p.Path & "\testlogin.mdb ")
Set rs = db.OpenRecordse t("login")
Do While Not rs.EOF
If txtUserName.Tex t = "Guest" And txtPassword.Tex t = "Guest" Then
Guest.Show
Exit Sub
End If
If rs.Fields("user name") = (txtUserName.Te xt) And _
rs.Fields("pass word") = (txtPassword.Te xt) Then
Form1.Show
Unload Me
Exit Sub
Else
rs.MoveNext
End If
Loop
txtPassword.Tex t = ""
MsgBox "Incorrect Password!", vbCritical
End Sub
Private Sub txtPassword_Los tFocus() <--------Here
txtPassword.Tex t = StrConv(txtPass word.Text, vbProperCase)
End Sub
Private Sub txtUserName_Los tFocus()
txtUserName.Tex t = StrConv(txtUser Name.Text, vbProperCase)
End Sub
Private Sub frmLogin_Load()
Data1.DatabaseN ame = (App.Path & "\testlogin.mdb ")
Data1.RecordSou rce = "login"
End Sub
I have a problem on a username password login form. I use:
txtPassword.Tex t = StrConv(txtPass word.Text, vbProperCase) to validate the
proper case when someone enters their name and password. It work when you
use the button to continue, but if you hit enter on your keyboard the event
apparently doesnt lose focus and it says you entered the wrong password. Is
there an easy fix for this. I pointed out the problem code below. Any help
would be appreciated.
Thanks,
Kelsey
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click ()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim db As Database
Dim rs As DAO.Recordset
Set db = OpenDatabase(Ap p.Path & "\testlogin.mdb ")
Set rs = db.OpenRecordse t("login")
Do While Not rs.EOF
If txtUserName.Tex t = "Guest" And txtPassword.Tex t = "Guest" Then
Guest.Show
Exit Sub
End If
If rs.Fields("user name") = (txtUserName.Te xt) And _
rs.Fields("pass word") = (txtPassword.Te xt) Then
Form1.Show
Unload Me
Exit Sub
Else
rs.MoveNext
End If
Loop
txtPassword.Tex t = ""
MsgBox "Incorrect Password!", vbCritical
End Sub
Private Sub txtPassword_Los tFocus() <--------Here
txtPassword.Tex t = StrConv(txtPass word.Text, vbProperCase)
End Sub
Private Sub txtUserName_Los tFocus()
txtUserName.Tex t = StrConv(txtUser Name.Text, vbProperCase)
End Sub
Private Sub frmLogin_Load()
Data1.DatabaseN ame = (App.Path & "\testlogin.mdb ")
Data1.RecordSou rce = "login"
End Sub
Comment