Database Properties

Applies To   Database object.

Description

The Database properties allow you to provide additional information about your database. To view the Database properties, click Database Properties on the File menu.

Setting

You can set these properties by entering information in the Summary or Custom tabs in the DatabaseName Properties dialog box or by using Visual Basic.

In Visual Basic, if a Database property hasn't already been set in the DatabaseName Properties dialog box, you must create the property by using the CreateProperty method and append it to the Properties collection of a Document object. With Visual Basic, you can set the properties that appear on the Summary tab by using the SummaryInfo Document object in the Documents collection. You set properties in the Custom tab by using the UserDefined Document object in the Documents collection. You must supply a name, data type, and default value for a custom Database property before you can add it to your database. For more information, the Documents collection specifics (Microsoft Access) in the "DAO Language Reference" part.

Note You can only enter or edit the properties that appear on the Summary or Custom tabs. The other Database properties are read-only.

Remarks

The Database properties appear in the DatabaseName Properties dialog box on the following tabs.

Tab

Description

General

This is the same information that is displayed when you right-click the name of a file in Windows Explorer and then click Properties on the shortcut menu. The only difference is that when these properties are viewed in Microsoft Access, the Attributes settings are read-only.

Summary

The information you enter on this tab is added to the SummaryInfo Document object in the Documents collection. This information is similar to the summary information you can provide in other Microsoft Office applications. Summary information allows the user to better identify a database both from within Microsoft Access and from other programs such as the Windows Find Files program.

The Hyperlink Base setting on the Summary tab is used to create the base hyperlink path that is appended to the beginning of relative HyperlinkAddress property settings.


(continued)

Statistics

This information includes the date and time the active database was created, and the last date and time it was modified, accessed, and printed.

Contents

This information includes the names of the objects contained in your database.

Custom

The custom properties you enter become properties of the UserDefined Document object in the Documents collection.


See Also   Append method ("DAO Language Reference"), Containers collection ("DAO Language Reference"), CreateProperty method ("DAO Language Reference"), Document object ("DAO Language Reference"), Documents collection ("DAO Language Reference"), Properties collection ("DAO Language Reference").

Example

In the following example, you can set or create a custom user-defined property that will appear on the Custom tab of the DatabaseName Properties dialog box. For example, you could call the SetCustomProperty function to add a new property called LastUserName to the UserDefined Document object in the database. The arguments passed to the SetCustomProperty function are those required to execute the CreateProperty method.

Dim strName As String, strValue As String

' Set property name variable.
strName = "LastUserName"
' Set property value variable.
strValue = InputBox("Please enter your full name")
If SetCustomProperty(strName, dbText, strValue) <> True Then
    ' Error occurred trying to set property.
    MsgBox "Error occurred trying to set property."
End If

Function SetCustomProperty(strPropName As String, intPropType _
    As Integer, strPropValue As String) As Integer

    Dim dbs As Database, cnt As Container
    Dim doc As Document, prp As Property

    Const conPropertyNotFound = 3270        ' Property not found error.
    Set dbs = CurrentDb                    ' Define Database object.
    Set cnt = dbs.Containers!Databases        ' Define Container object.
    Set doc = cnt.Documents!UserDefined    ' Define Document object.
    On Error GoTo SetCustom_Err
    doc.Properties.Refresh
    ' Set custom property name. If error occurs here it means
    ' property doesn't exist and needs to be created and appended
    ' to Properties collection of Document object.
    Set prp = doc.Properties(strPropName)
    prp = strPropValue                        ' Set custom property value.
    SetCustomProperty = True
SetCustom_Bye:
    Exit Function

SetCustom_Err:
    If Err = conPropertyNotFound Then
        Set prp = doc.CreateProperty(strPropName, intPropType, strPropValue)
        doc.Properties.Append prp        ' Append to collection.
        Resume Next
    Else                                        ' Unknown error.
        SetCustomProperty = False    
        Resume SetCustom_Bye
    End If
End Function
The next example demonstrates how to display information from the Summary tab of the DatabaseName Properties dialog box. The application's title, subject, and author are displayed in text box controls on a form. In this example, if the property hasn't already been set, "None" is returned from the procedure. If an unknown error occurs, a zero-length string (" ") is returned.

Private Sub Form_Open(Cancel As Integer)
    Dim strTitle As String, strSubject As String, strAuthor As String

    strTitle = "Title"
    strSubject = "Subject"
    strAuthor = "Author"

    Me!txtTitle = GetSummaryInfo(strTitle)
    Me!txtSubject = GetSummaryInfo(strSubject)
    Me!txtAuthor = GetSummaryInfo(strAuthor)
End Sub

Function GetSummaryInfo(strPropName As String) As String
    Dim dbs As Database, cnt As Container
    Dim doc As Document, prp As Property

    ' Property not found error.
    Const conPropertyNotFound = 3270
    On Error GoTo GetSummary_Err
    Set dbs = CurrentDb
    Set cnt = dbs.Containers!Databases
    Set doc = cnt.Documents!SummaryInfo
    doc.Properties.Refresh
    GetSummaryInfo = doc.Properties(strPropName)

GetSummary_Bye:
    Exit Function

GetSummary_Err:
    If Err = conPropertyNotFound Then
        Set prp = doc.CreateProperty(strPropName, dbText, "None")
        ' Append to collection.
        doc.Properties.Append prp
        Resume
    Else
        ' Unknown error.
        GetSummaryInfo = ""
        Resume GetSummary_Bye
    End If
End Function