2

In ms-access-2016 in the info section of the File menu, there is a link to View and Edit database properties. When the link is clicked a box comes up with 5 tabs, the right-most one is Custom. This tab provides an user interface to add custom properties to the database document.

I tested this by adding a Boolean property named "ask". This worked fine; it saves; it comes back after quitting and restarting. Now I want to access the property in vba.

I have enumerated the database properties with the following code:

Public Sub paEnumerateDatabaseProperties()
    Dim db As DAO.Database
    Dim prp As Property
    Set db = CurrentDb
    For Each prp In db.Properties
        On Error Resume Next
        Debug.Print prp.Name, prp.value, prp.Type
       If Err.Number <> 0 Then Debug.Print "Error: "; Err.Number, prp.Name
    Next prp
    Set prp = Nothing
    Set db = Nothing
End Sub 

Running this code creates a list of 51 of the 52 properties in the db.properties collection and one error for the connections property. But my custom Ask property is not in this collection. It wasn't in the application options collection either.

Anybody have an notion of where it is hiding? Thanks

Comintern
  • 21,855
  • 5
  • 33
  • 80
Perry Sugerman
  • 179
  • 1
  • 11

1 Answers1

3

Look for your custom property in a DAO.Document named "UserDefined" which is contained in the "Databases" container.

'For Each prp In db.Properties
For Each prp In db.Containers("Databases").Documents("UserDefined").Properties
HansUp
  • 95,961
  • 11
  • 77
  • 135
  • Thank you. This is what I was looking for. I prowled around Containers but failed to find Documents. You have been a big help – Perry Sugerman Sep 11 '18 at 04:56