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

More Permissions errors!!

Status
Not open for further replies.

lewatkin

Programmer
Mar 8, 2002
91
US
Hi gang,

I have a button that runs a macro, that in turn runs a function. I assigned permissions to the macro. When a user without permission clicks the button, that UGLY access permission error message pops up - which is good - permission is working. But I want to intercept that message and replace it with one that someone can actually understand. Another user pointed me in the right direction and what he suggested worked for a form error, but in this particular case, that does not work. An ideas?

Thanks in advance!

Lee
 
Lee,

I'm not sure exactly what your requirement is, and I'm probably not going to answer your question directly (sorry about that!). However, from what I understand about what you have written, here are a few hints which you might consider taking on board:

(a) Generally speaking, macros are a "poor relation" to modules. "Real programmers" dont need to use macros. Seriously though, anything you can do with a macro, you can do in code, and since you are using code anyway (you say your code runs a function), then it might be an idea to discard the macro, and incorporate its functionality directly into the "on click" event of the button. This way you end up with less objects in your application, which in turn makes it easier to work with.

(b) Add any appropriate permissions to the modules. What I suggest is that you give only developers permission to read the code. General users can only execute it.

(c) Rather than using the approach which gives certain users an error message when they press a button that they should not be pressing, I think that a better alternative is to simply hide the button from those users who are not intended to use it. For example, on the OnOpen event of a form, perform some test based on the User's login, and set the button's visible property to false if you dont want the user to have access to the button; Otherwise set the visible property to True.

(d) If you DO wish to customise error messages in a function or procedure, check out the "On Error" command in online help, or in an Access textbook. This will allow you to have full control of what the program does when an error is detected, including what message you send to the user, and what the program should do after the error is encountered.

Hope that this helps,
Cheers,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top