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

Read-only security access

Status
Not open for further replies.

ndltx5

Technical User
Jun 6, 2007
26
0
0
US
I have a group of users who are read-only and when they try to do certain things on the database, that because of security reason they aren't allowed, they get a "Run-time error." Is there a way to get rid of the error and instead have my own pop-up message that say something like "you do not have permission to do this," but only for read-only users.

Thanks alot
 
One way you can do this is to handle the run time error with an error handler to display the message you want like below:

The first line of your code of the even that brings up the error should be;
Code:
On Error GoTo Error_Handler
Then at the end if of the code put in something like this;
Code:
Exit Sub
Error_Handler:
If Err.Number = <enter the number of the error that appears in the runtime error box> Then
Msgbox "You do not have permission to do this",vbexlamation,"Security Error"
Else
Msgbox Err.Description
End if
 
The real solution is to identify a user that has readonly permission and conditionally execute the allowed code if they are not readonly.

How you do this is based entirely on how you implemented the read only permission... If you are using Jet/Access security, check out the currentuser function as a start.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top