Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Visual Dbase > Re: LostFocus E...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 38 of 132
Post > Topic >>

Re: LostFocus Event help

by "BeastFish" <beastfish@[EMAIL PROTECTED] > Dec 14, 2003 at 02:49 AM

Are the textboxes bound?  Do you have any code behind the text boxes'
KeyPress event that you didn't show here?  I ask because you said it
throws
an invalid password when you press enter.  The LostFocus event won't fire
until that control loses focus (who'd a thunk) when another control gets
focus.

If you wanted to, you can turn the enter key into a forward tab by
specifying which control to set focus to when the enter key is detected in
the textboxes' respective KeyPress events.  Something like...

Private Sub txtUserName_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
       KeyAscii = 0 ' bye bye beep
       txtPassword.SetFocus
    End If
End Sub

Private Sub txtPassword_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
       KeyAscii = 0 ' bye bye beep
       cmdOK.SetFocus
    End If
End Sub

Or to simplify it, you can just do this in each KeyPress event...
    If KeyAscii = 13 Then
       KeyAscii = 0 ' bye bye beep
       SendKeys "{TAB}"
    End If





"Randi" <RSaddler@[EMAIL PROTECTED]
> wrote in message
news:R9TCb.11784$JW3.8837@[EMAIL PROTECTED]
> 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
>
>
 




 4 Posts in Topic:
LostFocus Event help
"Randi" <RSa  2003-12-14 06:10:57 
Re: LostFocus Event help
"BeastFish" <  2003-12-14 02:49:10 
Re: LostFocus Event help
butlerbob@[EMAIL PROTECTE  2003-12-14 07:10:36 
Re: LostFocus Event help
"Steve Gerrard"  2003-12-14 10:53:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 5:50:47 CST 2008.