Results 1 to 8 of 8

Thread: [RESOLVED] set a 'Description' property of a dB?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Posts
    111

    Resolved [RESOLVED] set a 'Description' property of a dB?

    I use following code to set the 'Description' property of dB table property...

    Code:
    Set td = db.TableDefs(tablename) 'table name
        'set table 'Description' property
    td.Properties("Description") = tdDescription
    is there a way for me to set a 'Description' property of the dB itself (not a table within the dB)?
    Last edited by Jimboat; Jan 16th, 2021 at 04:17 PM.
    /Jimboat

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,864

    Re: set a 'Description' property of a dB?

    Looks like something from ancient times, perhaps DAO diddling with a Jet/ACE engine through its private API?

    As far as I can tell neither OLEDB nor ODBC define a table description property, though they both support column descriptions.

    No idea what a database "description" might be, but perhaps you are talking about extended property metadata that shows up via Explorer Properties dialogs? Does MS Access even offer a way to set/view this within its user interface? I'm not sure there is anywhere within Jet/ACE file formats to record such a thing.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Posts
    111

    Re: set a 'Description' property of a dB?

    dilettante - i don't know that such a property exists either? thinking that maybe can access the 'Summary' info part of dB creation? Could used 'Comment' property or 'Version' property. But can't find how to access to read or set these either.

    Can read/set the 'Description' of individual 'tables' within a dB, and use to record revision status/level of a table, but when there may be several tables in a single dB, how to read/set a 'description' or 'comment' or 'version' in the dB itself?
    /Jimboat

  4. #4
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,948

    Re: set a 'Description' property of a dB?

    The property "Description" is not used for the database object, but it has properties the same as tables do.
    You can add any new custom property to tables or the database itself:

    Code:
        Dim p As Property 
        
        ' test whether the property already exists
        On Error Resume Next
        Set p = db.Properties("Description")
        On Error GoTo 0
        
        If p Is Nothing Then
            Set p = db.CreateProperty("Description", dbText, "This is the default description")
            db.Properties.Append p
        End If
        
        ' test
        Debug.Print "Current: " & db.Properties("Description")
        
        ' modify
        db.Properties("Description") = "new description"
        
        ' test
        Debug.Print "New: " & db.Properties("Description")

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Posts
    111

    Re: set a 'Description' property of a dB?

    Quote Originally Posted by Eduardo- View Post
    The property "Description" is not used for the database object, but it has properties the same as tables do.
    Eduardo - Great! That'll work perfect! Thanks!
    Are there any already existing properties that the db object has, such as those like Title, Subject, Author, Manager, Company, Category, Keywords, Comments, that show in the Summary tab of the db Properties? Or do ALL of the properties need to be 'created' first?
    /Jimboat

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,864

    Re: set a 'Description' property of a dB?

    Support for this is limited.

    While it might be possible that a supporting property handler gets installed with later versions of MS Access, Windows (Shell32) itself does not seem to consider SummaryProperty values to be supported by MDB, ACCDB, etc.

    You can see that here:

    Code:
    Option Explicit
    
    'Assumes that DSO OLE Document Properties Reader 2.1 has been installed.
    '
    'See:
    '
    'https://docs.microsoft.com/en-us/office/troubleshoot/office-suite-issues/dsofile.dll-allow-edit-document-property
    
    Private Sub cmdCreate_Click()
        'Always use late binding for ADOX.  Microsoft failed to maintain binary compatibility.
        On Error Resume Next
        Kill ".\sample.mdb"
        On Error GoTo 0
        With CreateObject("ADOX.Catalog")
            .Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='.\sample.mdb'"
        End With
    
        'Use late binding for DSOFile just to be consistent, even though binary compatibility
        'should not be a problem.
        With CreateObject("DSOFile.OleDocumentProperties")
            .Open ".\sample.mdb", False
            .SummaryProperties.Author = "Fred Mertz"
            .Save
            .Close
        End With
        cmdDisplay.Enabled = True
    End Sub
    
    Private Sub cmdDisplay_Click()
        With CreateObject("DSOFile.OleDocumentProperties")
            .Open ".\sample.mdb", True
            MsgBox .SummaryProperties.Author, , "DSOFile"
            .Close
        End With
        'Always use late binding for Shell32.  Microsoft failed to maintain binary compatibility.
        With CreateObject("Shell.Application").NameSpace(App.Path)
            With .ParseName("sample.mdb")
                MsgBox .ExtendedProperty("System.Author"), , "Shell"
            End With
        End With
    End Sub
    
    Private Sub Form_Load()
        On Error Resume Next
        GetAttr ".\sample.mdb"
        cmdDisplay.Enabled = Err.Number = 0
    End Sub
    DSOFile can retrieve it, but Shell32 returns nothing (Empty).

    While System.Author can be set and retrieved by directly diddling the embedded OLE Storage, Shell32 does not normally have access to it.

  7. #7
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,948

    Re: set a 'Description' property of a dB?

    Quote Originally Posted by Jimboat View Post
    Eduardo - Great! That'll work perfect! Thanks!
    Are there any already existing properties that the db object has, such as those like Title, Subject, Author, Manager, Company, Category, Keywords, Comments, that show in the Summary tab of the db Properties?
    No, they are different things. These database properties are private and not archive tags.

    Quote Originally Posted by Jimboat View Post
    Or do ALL of the properties need to be 'created' first?
    I just created a new database and the default properties (and their values) are:

    Name: D:\db1.mdb
    Connect:
    Transactions: Verdadero
    Updatable: Verdadero
    CollatingOrder: 3082
    QueryTimeout: 60
    Version: 4.0
    RecordsAffected: 0
    ReplicaID:
    DesignMasterID:
    ANSI Query Mode: 0
    Themed Form Controls: 1
    AccessVersion: 08.50
    Build: 566

    I would not modify any of them, since they can be used privately by Access for something.

    Code:
    Private Sub Command1_Click()
        Dim db As Database
        Dim p As Property
        
        Set db = Workspaces(0).OpenDatabase("D:\db1.mdb")
        
        On Error Resume Next
        For Each p In db.Properties
            Debug.Print p.Name & ": " & p.Value
        Next
        
        db.Close
    End Sub

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Posts
    111

    Re: set a 'Description' property of a dB?

    Quote Originally Posted by Eduardo- View Post
    No, they are different things. These database properties are private and not archive tags.
    OK, thanks. i don't think i'll tamper with existing ones. Your 'private' properties are fine and will do the job. thanks again!

    /jim
    /Jimboat

Posting Permissions

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



Click Here to Expand Forum to Full Width