-----Original Message-----
This is driving me crazy...
Here is the entire procedure...it only works with my username (it's the
first record in the table).
Private Sub txtPassword_Change()
Dim intGoodPW As Integer
Dim intCurrentPW As Integer
Dim strCurrentPW As String
Dim strGoodPW As String
strGoodPW = Password
intGoodPW = Len(strGoodPW)
strCurrentPW = txtPassword.Text
intCurrentPW = Len(strCurrentPW)
If intCurrentPW = intGoodPW Then
If txtPassword.Text = DLookup _
("Password", "tblLogin", "[UserName]='" & Me.Username & "'") Then
Title.SetFocus
Else
'leave here
End If
End If
End Sub
Geof Wyght said:
Looks good. If Me.txtPassword.Value is the right one then
intGoodPW = intCurrentPW must be true right? Thinking of
your original idea, you want to compare intGoodPW =
intCurrentPW first and if they're equal do the DLookup. Of
course if the lengths are never equal, you must think of
an event to fire and tell them that something is wrong.
Speaking of logon ids you're aware that here's an API call
that gets a newtork id? It's handy.
Geof.
-----Original Message-----
Geof, what do you think about this?
If Me.txtPassword.Value = DLookup
("Password", "tblLogin", "[UserName]='" & _
Me.Username & "'") Then
If intGoodPW = intCurrentPW Then
Title.SetFocus
Else
'leave here
End If
Else
MsgBox "You entered an invalid password." &
vbCrLf & "Please try
again!", vbCritical, _
"Login Error"
With txtPassword
.SetFocus
.Value = ""
End With
End If
:
Antonio,
You're right. I gave a partial solution. In your first
post you didn't refer to a logon id. If you capture a
logon id you should be running a Select query to
retrieve
a record from your logonid table where the logonid is
the
same as the one that was entered. If you get a record,
that means the id is correct. Then you compare
passwords.
If you don't get a record then you kick them out. Does
that help?
Geof.
-----Original Message-----
Ok, Geof...there is something else. This is matching
up
the first password
it finds in the table, not for the specific user.....
Antonio
:
Antonio,
That's because you were comparing the length of the
current password with the actual good password
string
itself. Try something like this:
Private Sub Text0_Change()
Dim intLenGoodPW As Integer
Dim intLenCurrentPW As Integer
Dim strCurrentPW As String
Dim strGoodPW As String
strGoodPW = "howdy"
intLenGoodPW = Len(strGoodPW)
strCurrentPW = Me.Text0.Text
intLenCurrentPW = Len(strCurrentPW)
If intLenGoodPW = intLenCurrentPW Then
'do some more validation.
Else
End If
End Sub
Geof
-----Original Message-----
Geof, the OnChange event didn't fire....I had
something
like this:
if len(txtpassword)=password then
othercontrol.setfocus
end if
:
Antonio,
Try working with the OnChange event of the
password
text
box. Use the Len() function to check the length
of
the
value.
Geof.
-----Original Message-----
Good morning everybody...Here's my question:
On my login form, I would like users to enter
their
password and, when the
password typed is correct and it reached the
length
of
the password stored in
the table, I would like to set the focus to
another
control automatically
without having the user click or tab to another
control.
Hope this is clear.
Can anyone help me out? Thanks
.
.
.
.
.