Run Time Error 2603

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?
 
J

Joan Wild

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
 
D

dan.cawthorne

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 ?
 
D

dan.cawthorne

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?
 
J

Joan Wild

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.
 
D

dan.cawthorne

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
 
J

Joan Wild

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.
 
D

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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top