Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2010
    Posts
    1

    Unanswered: Setting OPEN/RUN Permissions for a form using ADOX

    I am trying to Set/Get the Group Permissions for a form in Access 2003 using ADOX. There are 4 Permissions that can be selected. Open/Run, Read Design, Modify Design and Administer.

    I can use SetPermissions/Getpermissions for Read Design, Modify Design and Administer but not Open/Run.

    If I unset all the four permissions via the Security interface the GetPermissions returns a zero. If I set the Open/Run permission and run GetPermissions it still returns a zero.

    Can anyone help please?

  2. #2
    Join Date
    Jan 2009
    Location
    Kerala, India
    Posts
    183

    Setting OPEN/RUN Permissions for a form using ADOX

    Open/Run Permission Values differ for each object groups like Form/Report, Database Object, Macros. In 2007 Open/Run permission setting is not there for Tables or Queries.

    Try the following Code for Form/Report and Macros:

    Code:
    Public Function SetOpenRun(ByVal dbPathName As String)
    Dim wsp As Workspace, db As Database
    Dim ctr As Container, doc As Document, UserGroup As String
    
    Const FormReportOpenRun As Long = 256
    Const dbOpenRun As Long = 2
    Const macroOpenRun As Long = 8
    
    UserGroup = "User or GroupName"
    
    Set wsp = DBEngine.Workspaces(0)
    Set db = wsp.OpenDatabase(dbPathName)
    Set ctr = db.Containers("Forms")
    For Each doc In ctr.Documents
        doc.UserName = UserGroup
        doc.Permissions = doc.Permissions Or FormReportOpenRun
    Next
    Set ctr = db.Containers("Reports")
    For Each doc In ctr.Documents
        doc.UserName = UserGroup
        doc.Permissions = doc.Permissions Or FormReportOpenRun
    Next
    
    Set ctr = db.Containers("Scripts")
    For Each doc In ctr.Documents
        doc.UserName = UserGroup
        doc.Permissions = doc.Permissions Or macroOpenRun
    Next
    
    Set ctr = Nothing
    Set db = Nothing
    
    End Function
    www.MsAccessTips.com (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

Tags for this Thread

Posting Permissions

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