user level cmnd button problem

undergrad

Registered User.
Local time
Today, 12:55
Joined
May 29, 2003
Messages
25
ok i have a button and it goes to a form that is restricted to the read only group i have established. when a member of this group clicks it won't let him saying he doesn't have permission to which is great. however i really don't like the error message bc it gives the option to debug the code. i don't want this at all. how can i get the error box to just essentially say sorry buddy you can't view this button..ok.

the error im getting is runtime error 2603. i have tried to set some code like if this happens then stop but i don't think i know what im doing. like should it be coding on the form "onerror" or "onclick" of the button or what.

any advice on this subject would be great

thanks!
 
If I understand you, you should be using the On Error funtion in your command button code.

Sorta like this

Sub cmdOpenForm click()

On Error goto Error_Open_Restricted_Form

'Your Open Form code

Exit Sub

Error_Open_Restricted_Form:

msgbox "You are not allowed to veiw this form. Your name will now be reported to the adminstrator and you will suffer horrible consequences"

End Sub

Of course the horrible consequences part is just for fun ;).

Pookatech
 
hey thanks that is great.

unfortunaley i get the new error message on entering as an allowed user. i can probally work that out though i just needed that initial coding direction.

Thanks again!
 
I'm guessing that your using access security here and have created a ReadOnly workgroup?

So what you need to do is either....

On click of button establish whether the user is in the read only group and if so pop up a message saying sorry bud....

or my preference....

On open of the form check if the use is in the group and if so, disable the button instead making it obvious that they cannot perform the function...

So how to check workgroups, try this bit of code, just pass in the name of your workgroup so "ReadOnly" or whatever!!!! If you don't pass in the user it will just assume you want the current user

Hope this sorts you out!




Function IsUserInGroup(strGrp As String, _
Optional strUser As String) As Boolean
'============================================================
' Purpose: Returns True if the user is is the group
' Programmer: Richard Jervis
' Date: 22/05/2001
'============================================================
On Error GoTo IsUserInGroup_Err
Dim strErrMsg As String 'For Error Handling
Dim grp As Group
Dim strUserName As String

'if no user supplied, assume current user
If strUser = vbNullString Then
strUser = CurrentUser()
End If

On Error Resume Next
With DBEngine.Workspaces(0)
Set grp = .Groups(strGrp)
strUserName = .Groups(strGrp).Users(strUser).Name
End With
IsUserInGroup = (Err = 0)

IsUserInGroup_Exit:
On Error Resume Next
Set grp = Nothing
Exit Function

IsUserInGroup_Err:
Select Case Err
Case Else
strErrMsg = strErrMsg & "Error #: " & Format$(Err.Number) & vbCrLf
strErrMsg = strErrMsg & "Error Description: " & Err.Description
MsgBox strErrMsg, vbInformation, "Error in IsUserInGroup procedure"
Resume IsUserInGroup_Exit
End Select
End Function;)
 

Users who are viewing this thread

Back
Top Bottom