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

Trouble with custom error message...

Status
Not open for further replies.

Pirates

MIS
Apr 28, 2002
3
US
I have Access Security on my db to secure the users from entering a couple of forms without proper premission. I'm trying to write my own error procedure to catch the runtime error 3603"Access Denied Error". My question where should I place the code on the click event event to entr the form or the open event?? I just can't seem to get anything to work
 
The error trapping code should be in the OnClick event procedure for the button where the command to open the form is.

I am running ACCESS 97 and the error that I receive for is:

2063 You don't have permission to run 'frmFormName' To run this object, you must have Open/Run permission for it.

I was able to trap for this error but I assume that you are using ACCESS version 2k etc. Correct? Err 3603 does not exist for ACCESS 97. But, it should work the same for the trapping situation.

Bob Scriver
 
This is how you should do it - in the Error code

Private Sub cmdOpenForm_Click()
On Error GoTo Err_cmdOpenForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "AnotherForm"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenForm_Click:
Exit Sub

Err_cmdOpenForm_Click:
If Err.Number = 3603 Then
' <do some action code here>
Else
MsgBox Err.Description
Resume Exit_cmdOpenForm_Click
End If
End Sub


Rod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top