Form Security

denileigh

Registered User.
Local time
Today, 22:28
Joined
Dec 9, 2003
Messages
212
I have a multi-user database and I have set permissions but I can't figure out how to protect a form from opening when you click the link from the custom menu.

I only want Admins to be able to view the employee form/personnel data.

Is there a way to do this?

Thanks!
 
One way is to put this in the forms OnOpen event...

If CurrentUser = "Admins" Then
DoCmd.Close acForm, "YourFormName"
MsgBox "You are not authorized to open the X form!"
End If

HTH
 
Thanks! I'll give that a try! Can I ask you one more question?

I have created a custom menubar and I can't figure out how to make the forms open in add mode from there.
 
Unless I don't have the permissions set right, that code didn't work. :(
 
If you have users and groups configured in the security feature, simply remove all priveleges for all other users apart from Admins for the form concerned. If you have a number of 'user' accounts I have found somtimes that setting the 'User' group permissions alone is not enough. Try setting the permissions for one 'User' user and testing.

Access should display a dialog informing of insufficient rights and the form should be prevented from opening.
 
denileigh,

I suggest that you verify who the current user is for my suggestion should work. Add this to the OnOpen event of the form...

MsgBox "Current User = " & CurrentUser

Also, removing the permissions as suggested above should work but that will prevent you from customizing a message to alert the user that they are not allowed to open that form.

You have to take an extra step since you are using a custom menu bar or tool bar. If you were using a custom navigation "main menu" form that displayed the command buttons to open each form in the db then you could set the visible property to "No" if the current user = "Admins" for a specific command button. That way the Admins users would never see the button to open a form that they are not allowed to open.

HTH
 

Users who are viewing this thread

Back
Top Bottom