Security Message Box

jboyle

New member
Local time
Today, 01:42
Joined
Nov 18, 2000
Messages
53
I have a database with user group security. If the user tries to go into an environment that they are not authorized, the system generated message box displays "You don't have permission to run bla bla bla". Is there a way to display a custom message box instead of the system generated messagebox?
Thank You - John
 
As long as the users in question have direct access to the database window, no. But if you use something called a "switchboard" form to get from point A to point B, then you can have an action routine that does the "Openxxx" for you. Look up "Switchboard" in the Help files or look in the Northwind Example - they have one there. It is really easy to build a switchboard, too. The Forms Wizard automatically triggers a wizard when you try to place a Command Button control. And "OpenForm" is one of the actions supported by the wizard, so it is a quick and dirty way to get the skeleton of your switchboard started.

If you use a switchboard then before the user actually opens the object you can look at its permissions. Assuming you want to see if the person has "Open/Run" on the object in question, you might call a function like this....

Somewhere in a convenient general module, define this:

Public function CanHeOpenFR( objIt as Object ) as Boolean

dim loMask as long

objIt.Username = CurrentUser
loMask = objIt.Permissions

CanHeOpenFR = ( loMask and acSecFrmRptExecute ) <> 0
end function

in the switchboard button code...

Private Sub RunXYZ_OnClick()

Dim dbCur as database
Dim frmTarget as form

set dbCur = CurrentDB

frmTarget = dbCur.Containers!Forms.Documents("your_form_name_here")
if not CanHeOpenFR( frmTarget ) then
msgbox "Customized_message_goes_here"
else
docmd.openform frmTarget.Name, etc.etc.etc.
end if

End Sub

You would need a separate routine for Macros because there is a Run permission for Macros that has a different value from the one for Forms and Reports.

Look up the topic of "Permissions" to find the list of all the constants related to this type of question. You might find other ways to "pretty up" your application by testing for other permissions as well.

The other "Gotcha" is that you can't allow your users direct access to the DB window. So that means you have to do things like turn off the menu bars and other features, then include a button to exit the application completely. But that is what it takes to exert complete control over where a user is permitted to go.
 

Users who are viewing this thread

Back
Top Bottom