Chow password gives me a strange result (1 Viewer)

scallebe

Registered User.
Local time
Today, 13:45
Joined
Mar 23, 2018
Messages
51
Good morning specialists,

I find a code on the web to show or hide the password in my Loginform.

Code:
Private Sub lbl_Click()
If Me.lbl.Caption = "Show Password" Then
Me.UserPassword.InputMask = True
Me.lbl.Caption = "Hide Password"
UserPassword.SetFocus
Else
Me.UserPassword.InputMask = "Password"
Me.lbl.Caption = "Show Password"
UserPassword.SetFocus
End If
End Sub

It works perfect but in my case my password = "3"

When I click the togglebutton the "*" schanges in W3r instead of 3

Once my password is longer e.g. 333 then it shows 333.

With 3 and 33 it shows W3r or W33r

Why is that?

Thanks

Greetz

Pascal:cool:
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:45
Joined
Feb 19, 2013
Messages
16,553
the inputmask property is text - you are giving it a value of -1 (true)

the usual way to use remove the password mask is

Me.UserPassword.InputMask = ""
 

isladogs

MVP / VIP
Local time
Today, 12:45
Joined
Jan 14, 2017
Messages
18,186
I don't get your result but the method isn't reliable.
Try typing longer password of more than four characters then click the button to hide the password. You will get an error

Either follow the advice by CJL or add a second textbox txtPassword of the same size and in the same position but with no input mask. Make this hidden by default

When you click the button or label (which needs a better name than 'lbl'), use code to show txtPassword and hide UserPassword or vice versa.

Whichever method you use, you should also ensure the cursor is moved to the start of the password using SelStart=0
This old post may help https://bytes.com/topic/access/answers/693616-changing-input-mask-code
 

scallebe

Registered User.
Local time
Today, 13:45
Joined
Mar 23, 2018
Messages
51
#CJ LONDON, #isladogs

Thanks for reply,

Once my DB is ready, I'm gonna use a longer password. Now I use a short one because it's easyer as long as I'm in the design mode of the DB.

I used both advices….

Here's the final code :
Code:
Private Sub btSeePW_Click()
If Me.btSeePW.Caption = "Show Password" Then
[COLOR="Red"]Me.UserPassword.InputMask = ""[/COLOR]
Me.btSeePW.Caption = "Hide Password"
UserPassword.SetFocus
[COLOR="red"]Me.UserPassword.SelStart = 0[/COLOR]
Else
Me.UserPassword.InputMask = "Password"
Me.btSeePW.Caption = "Show Password"
UserPassword.SetFocus
[COLOR="red"]Me.UserPassword.SelStart = 0[/COLOR]
End If
End Sub

Thanks a lot

Greetz

Pascal :cool:
 

Users who are viewing this thread

Top Bottom