[AccessD] Limiting User Navigation to Forms

Gustav Brock gustav at cactus.dk
Fri Sep 24 12:55:34 CDT 2004


Hi Karen

Yes, sort of.

In the OnOpen event of the form put:

  Cancel = IsUserAuthorized(Me.Name)

Then create a function:

  Public Function IsUserAuthorized( _
    ByVal strForm As String) As Boolean

    Const cstrMessage As String = _
      "You are not authorized to open this form."
    Const cstrTitle As String = _
      "Restricted Form"
      
    Dim lngAccessLevel As Long
    Dim booAccess As Boolean
    
    Select Case strForm
      Case "frmSome", "frmAnother"
        lngAccessLevel = 3
      Case "frmThird"
        lngAccessLevel = 4
      ' etc. ...
    End Select
    If GetUserAccessLevel() >= lngAccessLevel Then
      booAccess = True
    Else
      DoCmd.Beep
      MsgBox cstrMessage, vbInformation, cstrTitle
    End If

    IsUserAuthorized = booAccess
    
  End Function

The function GetUserAccessLevel() retrieves the access level of the
current user which you will have to define somewhere else.
  
/gustav


> I have about 50 users in 10 different departments.  Based on the user
> network login id, I want to limit the users ability to open up various
> forms - for instance, someone in the QA department would receive a "you
> are not authorized to open this form" message box  when they try to open
> up the AS departments data entry forms.  I don't want to have to code in
> each form that needs limitations an on open event to evaluate the id's
> and let those authorized through.  Has anyone built a table to hold
> network logins with passwords that are evaluated on form openings?  



> Karen Nicholson
> National Laboratory
> Xerox Global Services




More information about the AccessD mailing list