Password on a report

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

I have a database where I built a few switchboards to
allow users to drill down to their respective
departments. I have been trying to come up with a way to
prevent the printing of certain reports when the user
clicks on the control on the switchboard, where it would
prompt for a password to allow viewing and printing of the
report.

Thx
 
The command button could open a form (frmPassword)
containing a text box (txtPassword) and a command button.
You could set the format of txtPassword to Password to see
asterisks instead of the typed characters. Set the form's
properties to Pop Up and Modal. The command button's
event could be something like:

If Me.txtPassword = "Secret Password" Then
DoCmd.OpenReport "Secret Report"
Else
MsgBox "Invalid Password", vbCritical
End If
DoCmd.Close acForm, Me.Name

You could set DoCmd.Close... as part of the code if the
password is correct, and have the code for an incorrect
password be to clear txtPassword, or whatever combination
works best for your needs.
Alternatively, the report's On Open event could be:
DoCmd.OpenForm "frmPassword", , , , , acDialog

In this case the command button's On Click event would be:
Me.Visible = False
and the report's On Close event would be:
DoCmd.Close acForm, "frmPassword"
 
Back
Top