help with error message handling

Seasider

New member
Local time
Yesterday, 23:49
Joined
Jan 5, 2003
Messages
33
I've read many threads but have not been able to find anything that covers my current problem.

I've developed an application and set security for groups and users. The security is finally working well but one problem remains that I do not know how to solve.

When a user tries to open a form for which they do not have permission to open, the standard MS Access error message pops up and stays on the screen. At that point the user has the options to choose END or DEBUG. Needless to say, I don't want them going into Debug.

What I have been trying to do is to figure out a way that I can have one of my own messages pop up. After much reading and many failures, I don't know where to go from here.

Any suggestions on how to solve this?

Seasider
 
First of all, are you using VBA or macros?
 
error handling

Thanks for your reply. I am using VBA - I have not used any macros in the application. I'm quite new at Access and VBA.

Seasider
 
error handling solved

I found help for this problem in a book "VB and VBA In A Nutshell". I am posting the code in case it helps anyone else.

I placed the following code in the "onClick" event of the command button that opens the form.

Private Sub cmdOpenFunding_Click()

On Error GoTo NoPermission_Err

DoCmd.OpenForm "frmFunding", acNormal, , , acFormEdit, acWindowNormal

NoPermission_Err:
MsgBox "You do not have permission to open the Funding Form." & Chr(10), vbOKOnly, "Access to FUNDING Denied!"
Exit Sub
End Sub
 
Re: error handling solved

Seasider said:
Private Sub cmdOpenFunding_Click()

On Error GoTo NoPermission_Err

DoCmd.OpenForm "frmFunding", acNormal, , , acFormEdit, acWindowNormal

NoPermission_Err:
MsgBox "You do not have permission to open the Funding Form." & Chr(10), vbOKOnly, "Access to FUNDING Denied!"
Exit Sub
End Sub

Not quite:

Your error message will continue to be displayed whether you want it to or not. An exit sub at the end of completion would be useful.

Code:
Private Sub cmdOpenFunding_Click()

    On Error GoTo NoPermission_Err

    DoCmd.OpenForm "frmFunding", acNormal, , , acFormEdit, acWindowNormal

    Exit Sub

NoPermission_Err:
    MsgBox "You do not have permission to open the Funding Form." & Chr(10), vbOKOnly, "Access to FUNDING Denied!"
    Exit Sub
End Sub

VB & VBA In A Nutshell is a handy book.
 
error handling solved

Thanks so much for your help. I had already discovered that the message displayed even when I didn't want it. Appreciate your help.

Seasider
 

Users who are viewing this thread

Back
Top Bottom