Mask Password

Howlsta

Vampire Slayer
Local time
Today, 19:48
Joined
Jul 18, 2001
Messages
180
Hi,
I'm using the code below to put a password on the tabchange event. The problem is when the user enters the password - "password" it's not starred out, seeing as it's not a field I can't get rid of the problem with an input mask. Does anyone know how I can get the text entered into the input box to come up with stars pls?

Private Sub tabSwitchboard_Change()
Dim strPasswd

Select Case Me.tabSwitchboard.Pages. _
Item(Me.tabSwitchboard.Value).Name

Case "pagStaff"
strPasswd = InputBox("Enter Password", "Restricted Page")
If strPasswd = "Password" Then
Me.pagStaff.SetFocus
Else
Me.Page3.SetFocus
Exit Sub

End If


End Select

End Sub

Rich.
p.s How do you get the smiley faces to come up in posts. I'm jealous cos i can't do it!
 
I don't think you can modify how an input box works.
An option is to do it with a special form.

Put the following into your code:

Dim PasswordReturn As Variant
DoCmd.OpenForm "Form1"
Do
DoEvents
Loop Until Forms!Form1!Label1.Caption > 0
PasswordReturn = Forms!Form1!Label1.Caption
DoCmd.Close acForm, "Form1"
If PasswordReturn <> 1 Then
MsgBox ("Access not permitted")
Else
MsgBox ("Access Permitted")
End If


Make a small form (Form1) with:
A Text Box (Text1)
A Label (Label1)
A Command Button (Command1)

Form Properties:
Modal=Yes
Min/Max Buttons=None
Close Button=No

Text Box:
Input Mask=Password
On Change Event Code: If UCase(Forms!Form1!Text1.Text) = "PASSWORD" Then Forms!Form1!Label1.Caption = 1

Label:
Visible=No
Caption=0

Command Button:
On Click Event Code: Forms!Form1!Label1.Caption = 2
Caption=Cancel

The DoEvents loop recycles until the hidden label changes value to either a 1 for correct password or a 2 if the cancel button is pressed.

Smiley face info is found in the FAQ section.
 
That's a good way of doing it, I hadn't used that Doevents code before, so now I know how can use it in future.
smile.gif


Ric
 

Users who are viewing this thread

Back
Top Bottom