Hi All,
I have a problem on a username password login form. I use:
txtPassword.Text = StrConv(txtPassword.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(App.Path & "\testlogin.mdb")
Set rs = db.OpenRecordset("login")
Do While Not rs.EOF
If txtUserName.Text = "Guest" And txtPassword.Text = "Guest" Then
Guest.Show
Exit Sub
End If
If rs.Fields("username") = (txtUserName.Text) And _
rs.Fields("password") = (txtPassword.Text) Then
Form1.Show
Unload Me
Exit Sub
Else
rs.MoveNext
End If
Loop
txtPassword.Text = ""
MsgBox "Incorrect Password!", vbCritical
End Sub
Private Sub txtPassword_LostFocus() <--------Here
txtPassword.Text = StrConv(txtPassword.Text, vbProperCase)
End Sub
Private Sub txtUserName_LostFocus()
txtUserName.Text = StrConv(txtUserName.Text, vbProperCase)
End Sub
Private Sub frmLogin_Load()
Data1.DatabaseName = (App.Path & "\testlogin.mdb")
Data1.RecordSource = "login"
End Sub