Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password for opening a form 2

Status
Not open for further replies.

cwash

Technical User
May 27, 2002
45
US
I have a command button that promts the user to enter a pw to open a form. everything works good except for one thing. when the user enters the pw, the pw is spelled out instead of in ***'s. Below is the code for the command button. What is the code to 'hide' the pw when the user enters it and where do I put in within the code below. TIA

Private Sub Command1_Click()

Dim strPasswd

strPasswd = InputBox("Enter Password", "Restricted Form")

If strPasswd = "Type your password here" Then

DoCmd.OpenForm "FrmAmendDatabase", acNormal

Else

Beep

MsgBox "Only members of the Admin Group can amend this database application"

Exit Sub

End If

End Sub
 
I do not believe that you can format the entry of an InputBox. But you can create a small form with a text box that can be opened and have the password entered there. The InputMask of the text box on that form can be set to screen out the visible password with the following:

"Password" Setting the InputMask property to the word Password creates a password entry text box. Any character typed in the text box is stored as the character but is displayed as an asterisk (*).

Set the Password form to a Popup/modal form to make it stay on top until something is entered and the OK button is clicked.

This is the only way I believe to do what you want to do.

Bob Scriver
 
Hi Bob,

I'm very new to coding so I need help on a few things. I understand what you mean about setting up a form with a field to enter the pw. My problem is "how do you write the code that make the pw open the form?" Also, "where do you put the pw code?" The code from my original post was given to me. I'm learning as I ask and I'm learning as I see other's questions and answers.

If you can help with the coding, I would appreciate it.

TIA
 
Hey cwash,

I have a way you can achieve what you are trying to do.... I think..

It involves creating another little form to act as your input box to prompt the user for a password.

I am assuming you already have a form with a command button on it which is suppose to take the user to the other passord protected form.

We will call the form with the button to take the user to the pw protected form, original form.

We will call the form that prompts the user for the pw, pwform. And the pw protected form, last form.

Create the pwform with a textbox. set the input mask of this text box to password by selecting it from the properties. Create an OK button for the user to press when they have entered the pw.

On the original form put the code under the cmd button under "On Click"

docmd.openform "name of your password prompt form"

Then that bit is done.

Open your PWForm.

Select the OK button.

Go to the properties. and the ON click.

Paste the following code.....

Note that "PASSWORD" Is set as the actual Password.

'--------------------------------------

Dim strPasswd

strPasswd = "PASSWORD"

If Me.txtpw = strPasswd Then

'Name your textbox which the password will be entered into as txtpw

DoCmd.OpenForm "Name of your password protected form", acNormal

Else

Beep

MsgBox "Only members of the Admin Group can amend this database application"

Exit Sub

End If

'----------------------------------------------------

Hope this helps you, and you understand it.

I tryed to break it down for you as much as poss.

Any probs then let me know.

Let me know how you get on anyway.

Good Luck

Neemi
 
Hi Neemi,

Thanks for the reply. You broke it down pretty good, thank you! I do have one quesiton though..

I've got the three forms, PWprotectedForm, PWform, and LastForm. The PWprotectedForm has the command button that takes the user to the PWform, (asking the user to enter the password). On that same form, (PWform) I have a textbox, (for the user to enter the password) and the OK button.

How do I create the OK button. I don't know the code for this nor do I know where to put the code.

Please help.

After the user enters the correct password and clicks OK, they should then be taken to the LastForm. (Is this correct?)

I hope you can help
cw

 
Neemi, Hello again.

I figured out how to get the OK button to do what it's supposed to do. Now I have another problem.

After the OK is clicked, it does take me to the protected form.

Now how can I get the dialoge box to close on it's own. Right now I have to click on the X to close it.

Thanks again for your help!
 
cwash, I see that you and neemi have been working out your problem. In answer to your last question put the following in the OnClick event procedure of your OK button after the code you created to Open the Password protected form.

docmd.openform "name of your password prompt form"
docmd.close acForm, "PWform"

Remember to set the InputMask of your Password text box on your PWform to the word PASSWORD. That was your original question and that is the only way to get the "*******" to show as the user enters their password.

Good luck.

Bob Scriver.
 
Bob, thanks for the reply. I hope you don't think that I was ungrateful for your help. I was very grateful for your help and all others who offered their assistance.

I just get a little impatient when I'm pressed to figure out something I don't know how to figure out.

Let me say that I find these forums a lot more helpful then some classes I've taken. These forums are where I've learned the most. I also want to say that if it weren't for people like yourself and Neemi, and others, I would still be lost.

So, Thank you! and to all the others who take the time to answer all the 'simple' questions we new comers ask.
 
Oh no, I certainly wasn't upset with someone else helping on your problem. I only meant that I have been working all day and not available for more comments. Glad to see that neemi gave you the assistance that you needed.

Yes, these forums are probably the best place to really learn some of the detailed ins and outs of programming etc. When I was wading through the learning curve on ACCESS I didn't have anyone in our departments IT staff that I could turn to learn from. I was the leader in that aspect. But, hardly an expert at the time. Long days of trial and error solved problems.

This and other collaborative sites are what I wished I had a number of years ago.

Good luck

Bob scriver
 
cwash,

Did you get your problem sorted....

I hope my solution helped what you wanted to achieve..

To close ur dialog box you insert the extra line of code that scriverb suggested.

Hey scriverb,

Sorry to haver taken ova ur suggestion.

Good luck all.

Neemi
 
Neemi, that's okay. No one owns these things. You gave him just what I would have. I was at work all day and deep in alligator dodging. Good job.

Bob Scriver
 
Hello Neemi and Bob,

I was able to get my problem worked out, only with the help of you both.

Thanks again.

Please continue helping the newbies!
 
I know this is an old post, but it just helped me, so I give it a star [pc]

Graham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top