Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error Trapping error 2603 (Access 2k)

    Dear All

    I've set a few forms up so that certain user groups can't open them, however if code is run to open these forms they are offered the option of ending or debugging the code, not a simple message "No permissions", or whatever. I've got the standard error trapping in the code as attached. So what have I done wrong / missed?

    This is my first foray into Access Security and is causing a few grey hairs (OK it's the old age responsible for the grey, but I need summat to blame <img src=/S/grin.gif border=0 alt=grin width=15 height=15> ).Private Sub RejFollowUpBtn_Click()
    On Error GoTo ErrHandler

    DoCmd.OpenForm "FollowUpDataEntryFrm", acNormal

    ExitSub:
    Exit Sub

    ErrHandler:
    If Err.Number = 2603 Then
    MsgBox "You do not have access to this area of the database", vbOKOnly
    Resume ExitSub
    Else
    MsgBox Err.Description
    Resume ExitSub
    End If

    End Sub


    I've tried using a Select Case statement in my error handler, along the lines of: -
    Select Case Err.Number
    Case Err.Numbner = 2603
    msgbox Err.Description
    Resume ExitSub
    Case Else
    etc etc

    While I can change the message on the pop up de###### form, I can't prevent the thing from offering the user the option to view my code. They are not allowed to edit it, that much works, but it is not as 'neat and tidy' as I like to have a system.

    Thanks

    Ian

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Error Trapping error 2603 (Access 2k)

    First of all, we usually try to prevent someone from ever getting to the point where they can try to open a form (via code) by hiding buttons and so forth based on UserGroup. That get's pretty tricky with Switchboard driven systems however, so you probably do need some error handling. First of all, are you sure the error is always 2603? It seems to me I've seen others as well that are related to security. Your code looks to be OK from what I can see - but be aware that from 2000 on, the code is not covered by the security scheme. So you may want to look at other methods of protecting your code as well. Once solution is to deploy an MDE version of the code, so you can't even open the VBA de######. Hope this helps.
    Wendell

  3. #3
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error Trapping error 2603 (Access 2k)

    Wendell

    Thank for the info, yes, so far I've only had error 2603 when a form is accessed by someone without permissions for it.

    Is there anyway I could check the user group with the code on the button, or on the on open event for the form? Surely if I can do this I can set the buttons visible property?? I'm grasping at straws here with a limited knowledge of the security model.

    Thanks

    Ian

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Error Trapping error 2603 (Access 2k)

    Yes, there is a way to check for UserGroup, though in 2000 it's fairly convoluted. It's simpler in 2002 as there is some native support for lookup of UserGroup. For 2000, the Access Developer's Handbook has lots of details as to how to do that. You may find it simpler to check for a small number of user names than to try to write lots of code behind multiple forms.
    Wendell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •