Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Permissions changing when files opened (1.0)

    I have an application with linked tables. The main application has it's own workgroup file. I wanted to distribute an updated tables database that would contain the original tables plus some new tables and some additional fields.

    I created a third program which is a utility database that imports all the tables, modifies them,creates a new database called "Updated Tables" and exports all the modified tables from my utility database to "Updated Tables". I use the same workgroup file when opening the utility as I do when opening the main application.

    The problem:
    The utility reads the existing tables database mSysObject file to get a list of table names to import. When I run it, I get an error 3112 "Records cannot be read; no read permission on 'MSysObjects'."

    Now here is the twist.

    If I
    - Close the utility but leave Access open (remember it was opened using the special workgroup file)
    - I can open the main application (the one the tables link to). No surprises yet.
    - If I now close the main application (leaving Access still open) and reopen the utility, it runs without the error 3112.

    So what changes at a security level when different databases are opened without Access being closed?

    The actual code is
    strOldTables = Forms!frmUpgrade.txtLocation ' The file to import from

    strSQL = "SELECT DISTINCT MSysObjects.Name, MSysObjects.Type FROM MSysObjects " & _
    "WHERE MSysObjects.Name Not Like ""msys*"" AND MSysObjects.Type=1;"

    Set dbs = OpenDatabase(strOldTables) ' Nominate the database

    Set rst = dbs.OpenRecordset(strSQL) ' Import the table names

    The error occurs here

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

    Re: Permissions changing when files opened (1.0)

    Hans or someone else may correct me here, but I don't believe you can open the MsysObjects table from a database other than the current database. You might want to look at using the tabledefs collection instead of copying table names. Of course you can also import linked tables directly, and it preserves the link information.
    Wendell

  3. #3
    New Lounger
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Permissions changing when files opened (1.0)

    Hi Wendell
    Thanks for replying. I actually can open theMSysObjects if I close my utility program, open the main application, close the main application and reopen the utility program - all the time leaving Access open. The problem seems to be that by opening different applications in an Access session, permissions change.

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

    Re: Permissions changing when files opened (1.0)

    Hi Neville,
    My gut instinct is that think this isn't actually a security permissions issue, but one associated with database ownership. Is the login ID you are using shown as the owner of each of the databases? When you close a database, I think there is some residual connection left to the database - you can verify that by checking to see if the lock file for that database is still open, assuming you are working in a single-user mode. I think it is that mechanism that lets you work with the msysObjects table after you have had the database open in the current Access session.
    Wendell

  5. #5
    New Lounger
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Permissions changing when files opened (1.0)

    Hi Wendell
    It gets weirder!!! I checked your record locking suggestion and it lead nowhere. ldb files were created and stayed unchanged as other files were opened and closed. I then looked at the file I opened that seemed to make it work. After running through an autoexec macro that fired up a few functions, I found the function that seemed to make my utility work when it was opened. This was a process of trial and error. Comment out everything until you could uncomment a line and make the utility work.

    Here is what makes it all happen. When I open the main form in my utility, I run the following functions.


    Function funTest()
    ChangeProperty "AllowShortcutMenus", dbBoolean, True
    End Function

    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim dbs As Database, prp As Property
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo Change_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

    Change_End:
    Exit Function

    Change_Err:
    If Err = conPropNotFoundError Then ' Property not found.
    Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
    dbs.Properties.Append prp
    Resume Next
    Else
    ' Unknown error.
    ChangeProperty = False
    Resume Change_End
    End If
    End Function

    I have tried running other changepropertys and they all work so it is something in the called function (Function ChangeProperty). I can drill down further and try each line of code to see where the problem is being rectified. The night is too late to do it today.

    It is one thing to say the program now runs. It is another to know what the problem is. I want to get to the bottom of it and resolve the cause rather than treat a symptom with an obscure remedy. I would appreciate your thoughts.

Posting Permissions

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