Password Field Autotab

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Antonio,
Try working with the OnChange event of the password text
box. Use the Len() function to check the length of the
value.
Geof.
 
Geof, the OnChange event didn't fire....I had something like this:

if len(txtpassword)=password then
othercontrol.setfocus
end if
 
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
 
Thank you, Geof, it worked!!

Geof Wyght said:
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
 
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,
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.
 
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
 
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]='" & _
 
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,
I reproduced this and it was hanging up on me. After
entering the 3rd letter or so, I coudn't enter any more
letters, nor would the change event fire. If I put the
focus to another text box and returned to the password
text biox then the cahnge event would fire again. Why not
try the after update event? By the way, I
assume "Password" is coming from somewhere? I had to make
it a constant.
Geof.
-----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
.


.


.


.
.
 
Password is the field in the table to lookup.
Here's why I wanted to verify the password and the length of the password:
On the form I have 2 labels: "Edit User Information" and "Add User". Once
the password is entered and the user click on one of these labels, they will
receive an error message stating that they have to enter the password in
order to Edit their information. That's because the password they entered is
not yet "registered" until the txtpassword field looses the focus, so that's
why I can't use the AfterUpdate event. The username is a drop-down box,
where users select their name from. After selecting their name, the
txtpassword receives the focus. Hope this is clear. Antonio

Geof Wyght said:
Antonio,
I reproduced this and it was hanging up on me. After
entering the 3rd letter or so, I coudn't enter any more
letters, nor would the change event fire. If I put the
focus to another text box and returned to the password
text biox then the cahnge event would fire again. Why not
try the after update event? By the way, I
assume "Password" is coming from somewhere? I had to make
it a constant.
Geof.
-----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
.


.


.


.
.
 
Antonio,
You said that "Once the password is entered and the user
click on one of these labels, they will receive an error
message stating that they have to enter the password ..."
You're asking them to enter the password twice? Also, in
your previous post, you said "This is driving me crazy..."
but you didn't say why.
Geof.
 
No, Geof, I am not asking twice, but after they enter the password, and the
txtpassword still has the focus, the field hasn't been updated, yet, until it
looses the focus, so, if they click on the label, the password they entered
is still null (until the text box looses the focus)...it's driving me crazy
because I can't figure it out...Antonio
 
Antonio,
I noticed that after you enter the 1st letter of the
password, Me.txtPassword.Text is not null but
Me.txtPassword.Value is. Does that help?
Geof.
 
Back
Top