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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password protecting a report 1

Status
Not open for further replies.

JanesC

Technical User
Jan 15, 2002
29
GB
When a user clicks on a button to print a report on my main menu i would like a dialogue box to come up and ask for a password.
When they enter the password i would like ***** to appear so no one else can read it.
I have been looking through the old posts and i understand you can't have an input mask on a dialogue box so i will have to create a form to act as the password dialogue box.

How do i get the form to work? Do i need to setup a bound field in the form, do i use 'after update'?

Thanks
 
Change everything in red accordingly:

1) Create a small form that looks like a dialog box with one unbound text box named txtPassword, and two buttons, cmdOK (caption "O&K", and cmdCancel (caption &Cancel).
2) Make the input mask on the text box "Password"
3) Set the following properties of the FORM

Caption = " Enter Password"
Scroll bars = Neither
Record Selectors = No
Navigation buttons = No
Dividing Lines = No
Auto Resize = Yes
Auto Center = Yes
Popup = Yes
Modal = Yes
Border Style = Dialog
Control Box = No
Min Max Buttons = No
Close Button = No

4) Put the following line of code in the General Declaration section of the form:

Private Const PWD As String = "YourPasswordHere"

5) Put the following code on the OnClick of the OK button:

If Me.txtPassword = PWD Then
DoCmd.OpenReport "YourReportNameHere"
DoCmd.Close acForm, "frmPassword"
Else
MsgBox "The password you entered is incorrect, please try again."
Me.txtPassword.SetFocus
End If

6) Put the following line of code on the OnClick of the Cancel button:

DoCmd.Close

7) Close and save the form (frmPassword)
8) The code on the button on the main form should say this:

DoCmd.OpenForm "frmPassword

This is using a private constant on the form as the password. There are several options, you could use a global variable, or even a value in a table. Jim Lunde
compugeeks@hotmail.com
We all agree your theory is crazy, but is it crazy enough?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top