Passwords

J

Jim/Chris

Here are two methods from Howard Brody and Matt Weyland

On the click event for the button add the following code.

dim strPW as string

strPW = inputbox("Please enter password to go to next
form","Enter Password")

if strPW = "password" then 'or what ever you want it to be
docmd.openform "Next form"
else
msgbox "The password did not match, please try again."
end if

That should do it.

Matt Weyland

Or

Try this code in the OnClick event for the CommandButton:

Private Sub cmdGoToNextForm_Click()

' declare variables
Dim strMsg As String
Dim strPW As String

' prompt user for password
strMsg = "Please enter the password for the next form:"
strPW = InputBox(strMsg)

' compare entered password to actual password ("LetMeIn") and
' either open the nect form or display an error message
(depending
' on whether it matches)
If strPW = "LetMeIn" Then
DoCmd.OpenForm "frmNextForm"
DoCmd.Close acForm, Me.Name
Else
strMsg = "You entered an incorrect password."
MsgBox strMsg, vbOKOnly, "Oops!"
Exit Sub
End If

End Sub

Hope this helps!

Howard Brody
..

Jim
-----Original Message-----
Can you create a macro to require a password and tie it to
a cmd button. So that upon click you are required to enter
a password to access where ever the cmd button takes you
(ie and Administration switchboard). Thanks.
 
S

Steve Schapel

Brad,

Since this is a macros newsgroup, I answered accordingly. The kinds of
methods suggested by Jim use vba procedures, not macros. They are no
more secure in themselves, but could be made more secure if the database
application was converted to an MDE format file, in which case the
hard-coded password in the code would be inaccessible.
 

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