Run Time Error 2603

  • Thread starter Thread starter dan.cawthorne
  • Start date Start date
D

dan.cawthorne

How do change the error message thats prompted when a User opens a
form that they don't have permission to open

instead of the standard end and debug buttons on the menu with the
error run time error 2603 been displayed

i just want a simple message box that with a OK button on it.

ive tried putting some code on the on error event of the form, from
another article but not luck.

i tried following.

Private Sub Form_Error(DataErr As Integer, Response As Integer)

On Error GoTo Errorfnc_mnuOpen_Err

Errorfnc_mnuOpen_Err:
If Err = 2603 Then

If MsgBox("You do not have the necessary permissions to_ view
this menu option. Consult your system administrator") = vbOK Then
'simply end the function
End If
Exit Function ' if it's a sub then Exit Sub
End If

End Sub

This code dose not have any effect.

My form im opening from via command button is MainMenu and the Command
Button opens a form called "Admin_Menu"

any idea's?
 
Perhaps a better approach would be to hide the button, so the user doesn't even see it.

There is code in the security FAQ you can use to determine if a user is a member of a group.
If faq_IsUserInGroup("NameOfGroup",CurrentUser) then
Me.NameOfCommandButton.Visible = False
Else
Me.NameOfCommandButton.Visible = True
End If
 
Perhaps a better approach would be to hide the button, so the user doesn't even see it.

There is code in the security FAQ you can use to determine if a user is a member of a group.
If faq_IsUserInGroup("NameOfGroup",CurrentUser) then
Me.NameOfCommandButton.Visible = False
Else
Me.NameOfCommandButton.Visible = True
End If

That could work, so would i but that code on my form with the button?

and would if need to assign it to an event command, if so which one?
would it be on open event. And Where do i find the security FAQ ?
 
You'd use the Form's Open Event. The security FAQ can be found at
http://support.microsoft.com/?id=207793

Ive tried this code?

Private Sub Form_Open(Cancel As Integer)

If faq_IsUserInGroup("NormalUsers", CurrentUser) Then
Me.Command18.Visible = False
Else
Me.Command18.Visible = True
End If

End Sub

and the If Faq_IsUserInGroup is high lighted in the compile error, you
now why?
 
Ive tried this code?

and the If Faq_IsUserInGroup is high lighted in the compile error, you
now why?

Did you copy the code from the security FAQ? You need to copy the faq_IsUserInGroup() function code from the FAQ into a module.
 
Did you copy the code from the security FAQ? You need to copy the faq_IsUserInGroup() function code from the FAQ into a module.

Hi Joan,

Thanks for the Assistance

I couldnt find the related code in the FAQ! but i manage to get this
code to work on the event click on the button,

Private Sub cmdbutton_Click()
On Error GoTo ErrorcmdButton

DoCmd.OpenForm "Admin_Menu", acNormal
DoCmd.Close acForm, "MainMenu"

ExitcmdButton:
Exit Sub

ErrorcmdButton:

' Traps permissions error message
If Err = 2603 Then

MsgBox "You do not have access to this Section"
Resume ExitcmdButton

End If

End Sub

And Works Great

Regards

Dan Cawthorne
 
OK, if you're happy with that approach. I usually find that users get annoyed with messages like that - being presented with an option and then told 'not for you'.

The function is in section 22 of the faq.
 
OK, if you're happy with that approach. I usually find that users get annoyed with messages like that - being presented with an option and then told 'not for you'.

The function is in section 22 of the faq.

Thanks, I Will Give it Another Try and see, which one i prefer, i
suppose its the only way at learning new skills at access
 
Back
Top