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

I NEED HELP WITH SECURING A REPORT CODE

Status
Not open for further replies.

chubby

Programmer
Apr 28, 2001
278
US
All of the Department heads want there finance reports for their department password protected so know one outside the department can review their finances. So I attach some code to the open button. It works (that is keeps others out) but the after you hit okay (if you don't have access to that report) it comes up with an error MSG. But it lets you proceed on. I just hate that error MSG. Can anyone help me correct this problem with my code please....

Option Compare Database
Option Explicit

Private Sub Report_Open(Cancel As Integer)

On Error GoTo ErrFO
If ((CurrentUser() <> &quot;phm2600a&quot;) And (CurrentUser() <> &quot;phm7674b&quot;) And (CurrentUser() <> &quot;phm0000&quot;) And (CurrentUser() <> &quot;phm0000&quot;)) Then
MsgBox &quot;ACCESS DENIED.&quot;
Cancel = True
End If

ExitFO:
Exit Sub

ErrFO:
MsgBox Err.Description, vbInformation, &quot;Report Open Error.&quot;
Resume ExitFO
End Sub
 
Well, I'm not an expert in security and someone else may have a more efficient suggestion for you, but here is what I do.

I wouldn't put your security check in the open event of the report. I think it may be too late to close the report at that point. I would create a form with command buttons for the users to push which would then open and process the reports. You can then put your security in the click event of those buttons.

B-)
 
Maquis:

The problem with that is if the user can get at the database window, then they can just bypass the security built into the buttons. The OnOpen event works better in this respect.

As for the question, you have code in your OnError, wouldn't removing that code make the error go away?

Joe Miller
joe.miller@flotech.net
 
Don't let your users get to the database window. I always lock down my databases, not only for data security, but also so that they do not change any of my database design. (It makes maintaining them a nightmare)

Under Tools --> Startup
Enter a form to display on startup and
uncheck &quot;Display Database Window&quot;
uncheck &quot;Allow Full Menus&quot;
uncheck &quot;Allow Built-in Toolbars&quot;
uncheck &quot;Allow Toolbar/Menu Changes&quot;

Warning: after you do all that, the only way to get into the database's design will be to &quot;shift into&quot; it. (Hold the shift key down as you click on the database to open it.)
Most users don't know about that little trick, but if you would also like to display the shift trick then read this faq181-143
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top