Password in *

A

Adamfunchal

I have this code to protect a form when I press a command button. My question
is: When I input my password everyone can see my password, how can I input my
password and show "*****", for no one see my password?

Private Sub AddFuncionário_Click()

Dim strPasswd

strPasswd = InputBox("insert password", "restrict form")

'See if a valid entry made to input box

If strPasswd = "" Or strPasswd = Empty Then
MsgBox "Can not be empty.", vbInformation, "Needed"
Exit Sub
End If

'correct password is entered open Main form Close, Opening Sheet

If strPasswd = "MYpassword" Then
DoCmd.OpenForm "FormName", acNormal
Else
MsgBox "Sorry", vbOKOnly, "Important "

Exit Sub
End If
End Sub
 
D

Douglas J. Steele

You can't using the InputBox function.

You'll have to create your own form with a text box on it, and set the text
box's InputMask.
 
A

Adamfunchal

Sorry my ignorance, But how i do that? whats the code?

Thanks
"Douglas J. Steele" escreveu:
 
A

Adamfunchal

I´ve created a form called Password with an input box where i write my
password and it shows "******", and a button Called OK. I press that button
and open the protcted form. Now I want to know which is the code I put in the
Ok button to see if the password is correct or not.
Can someone help me?

"Douglas J. Steele" escreveu:
 
K

Keith Wilby

Adamfunchal said:
I´ve created a form called Password with an input box where i write my
password and it shows "******", and a button Called OK. I press that
button
and open the protcted form. Now I want to know which is the code I put in
the
Ok button to see if the password is correct or not.
Can someone help me?

Assuming the text box name is "txtPWD" and the password is "MyPassword":

If Me.txtPWD = "MyPassword" Then
'Do something
Else
MsgBox "Wrong password"
'Do something else
End If

HTH - Keith.
www.keithwilby.com
 
A

Adamfunchal

I've a database with 3 or 4 buttons that opens others protected forms. Its
possible use the same password form to open other forms?If so, how can i do
that?
If I use a code like:

If Me.txtPWD = "MyPassword" Then
DoCmd.OpenForm "FormName", acNormal

It only opens the form "FormName" and wont open "FormName1" e.g


"Keith Wilby" escreveu:
 
K

Keith Wilby

Adamfunchal said:
I've a database with 3 or 4 buttons that opens others protected forms. Its
possible use the same password form to open other forms?If so, how can i
do
that?
If I use a code like:

If Me.txtPWD = "MyPassword" Then
DoCmd.OpenForm "FormName", acNormal

It only opens the form "FormName" and wont open "FormName1" e.g

Attach a copy of the code to each button's click event but change the name
of the form to the one you want to open.
 
A

Adamfunchal

I think you dont understand me.
I've a form with 4 buttons and "PassworForm" with 2 buttons: "OK" and
"Cancel". when I press "Button1" it opens "PasswordForm" and after input
password I press "OK" and opens "Form1".
when I press "Button2" it opens "PasswordForm" and after input password I
press "OK" and opens "Form2" and so on.
Is it possible? how can i do this? I tried to attach a copy of code to each
button's click event but changing the name of the form to the one I want to
open and it dont work.


"Keith Wilby" escreveu:
 
K

Keith Wilby

Adamfunchal said:
I think you dont understand me.
I've a form with 4 buttons and "PassworForm" with 2 buttons: "OK" and
"Cancel". when I press "Button1" it opens "PasswordForm" and after input
password I press "OK" and opens "Form1".
when I press "Button2" it opens "PasswordForm" and after input password I
press "OK" and opens "Form2" and so on.
Is it possible? how can i do this? I tried to attach a copy of code to
each
button's click event but changing the name of the form to the one I want
to
open and it dont work.

Ah, in that case pass the name of the form you want to open to
"PasswordForm" using the OpenArgs property:

Button1_Click:
DoCmd.OpenForm "PasswordForm",,,,,,"Form1"

Button2_Click:
DoCmd.OpenForm "PasswordForm",,,,,,"Form2"

.... and so on. Then in "PasswordForm" OK button's Click event:

DoCmd.OpenForm Me.OpenArgs

The form named in the OpenArgs property will open.

HTH - Keith.
www.keithwilby.com
 
A

Adamfunchal

Thats not working

I write in the Button1_Click:
Private Sub Button1_Click()
DoCmd.OpenForm "PasswordForm", , , , , , "Form1"
End Sub

In the Button2_Click:
Private Sub Button2_Click()
DoCmd.OpenForm "PasswordForm", , , , , , "Form2"
End Sub

And so on...

In the PasswordForm OK Button i write:
Private Sub OK_Click()
If Me.TxtPWD = "MyPassword" Then

DoCmd.OpenForm Me.OpenArgs


Else
MsgBox "Wrong Password."
'Do something else
End If

End Sub


And it only works with Button1 and open form1

In the other ones it give me an error "Run-Time error '2494'".
What is wrong?

"Keith Wilby" escreveu:
 
K

Keith Wilby

Adamfunchal said:
Thats not working

I write in the Button1_Click:
Private Sub Button1_Click()
DoCmd.OpenForm "PasswordForm", , , , , , "Form1"
End Sub

In the Button2_Click:
Private Sub Button2_Click()
DoCmd.OpenForm "PasswordForm", , , , , , "Form2"
End Sub

And so on...

In the PasswordForm OK Button i write:
Private Sub OK_Click()
If Me.TxtPWD = "MyPassword" Then

DoCmd.OpenForm Me.OpenArgs


Else
MsgBox "Wrong Password."
'Do something else
End If

End Sub


And it only works with Button1 and open form1

In the other ones it give me an error "Run-Time error '2494'".
What is wrong?

I don't know what that error is but I've just simulated my suggestion and it
works perfectly. You need to double-check your code. Does your code
compile? Have you tried stepping through the code at run-time to make sure
that OpenArgs has a value?
 
A

Adamfunchal

I dont Know what was wrong, but now its working. Thanks
Now I want to know if is possible close "passwordForm" after press "OkButton".

If so, how can i do that? I've tried so many ways and no one works. :eek:(

"Keith Wilby" escreveu:
 
K

Keith Wilby

Adamfunchal said:
I dont Know what was wrong, but now its working. Thanks
Now I want to know if is possible close "passwordForm" after press
"OkButton".

If so, how can i do that? I've tried so many ways and no one works. :eek:(

DoCmd.Close acForm, Me.Name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top