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

How can I Password protect a report

Status
Not open for further replies.

TrailblazerLS

Technical User
Sep 26, 2006
26
0
0
US
A manager has requested that I password protect a report.
They don't want the other users to see it. Off the top of my head I am not sure how to accomplish this.
Is there a good way to do this.
 
A simple (easily foiled) method is to add code to the On Open event of the report like:
Code:
Private Sub Report_Open(Cancel As Integer)
    Cancel = InputBox("Enter Password:", "PWD Please") & "" <> "Open Please"
End Sub
The user could open the design view of your report and find the code unless you created an MDE.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Hi,

Hi,

Depends on your version of Access, network sw etc, but try this also:

In the <event> that calls the report:
Code:
if((Environ("Username") = "Fred.bloggs") or (Environ("Username") = "Admin_name")) then
	'run report' code
else
	msgbox "Sorry - this report is currently undergoing changes"
endif

ENVIRON checks the user log-on name.

Replace "Fred.bloggs" and "Admin_name" with all employees that CAN view the report (you may have to add more 'OR's).

ATB

Darrylle

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
I would not use ENVIRON() since I don't think it is always available and accurate. There is an API at which is more reliable.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top