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 the Database Properties command on the File menu.

Setting

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

In Visual Basic, if a Database property has not already been set in the Database Properties dialog box, you must create the property using the CreateProperty method and append it to the Properties collection of a Document object. You set properties in the Summary tab using the SummaryInfo Document in the Documents collection. You set properties in the Custom tab using the UserDefined Document in the Documents collection. You must supply a name, data type, and default value for a custom property before you can add it to your database.

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

Remarks

The Database properties appear in the Database Properties dialog box under the following tabs:

General

This is the same information that is displayed when you right-click on a filename using the Windows Explorer and choose the Properties command. The only difference is that when viewed in Microsoft Access, the Attributes settings are read-only.

Summary

Choose the Summary tab to add summary information about your database. The information you enter is added to the SummaryInfo Document 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 to outside programs such as the Windows 95 FindFile program.

Statistics

Choose the Statistics tab to view information about your database. This information includes the date and time the active database was created, the last date and time it was modified, accessed, and printed.

Contents

Choose the Contents tab to see a list of the names of the objects contained in your database.

Custom

Choose the Custom tab to view, add, or modify custom database properties. The custom properties you enter become properties of the UserDefined Document in the Documents collection.

Example

In the following example you can set or create a custom user-defined property that will appear on the Custom tab of the Database Properties dialog box. For example, you could call the SetCustomProperty function to add a new property called UserName to the UserDefined Document 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.= "LastUserName"
' Set property value variable.= InputBox("Please enter your full name")SetCustomProperty(strName, dbText, strValue) = True Then
    ' Property was successfully set.
    ' Error occurred trying to set property.If
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 an error occurs here it means the
    ' property does not exist and needs to be created and appended
    ' to the properties collection of the document object.
    Set prp = doc.Properties(strPropName)
    prp = strPropValue                       ' Set custom property value.
    SetCustomProperty = True_Bye:
    Exit Function_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 IfFunction

The next example demonstrates how to display information from the Summary tab of the Database Properties dialog box. The application title, subject, and author are displayed in text box controls on a form. In this example, if the property has not already been set then “None” is returned from the procedure. If an unknown error occurs then 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)
Sub
GetSummaryInfo(strPropName As String) As String
    Dim dbs As Database, cnt As Container
    Dim doc As Document, prp As Property
    Const conPropertyNotFound = 3270            ' Property not found error.
    On Error GoTo GetSummary_Err
    Set dbs = CurrentDb()                    ' Define Database object.
    Set cnt = dbs.Containers!Databases        ' Define Container object.
    Set doc = cnt.Documents!SummaryInfo        ' Define Document object.
    doc.Properties.Refresh
    GetSummaryInfo = doc.Properties(strPropName)_Bye:
    Exit Function_Err:
    If Err = conPropertyNotFound Then
        Set prp = doc.CreateProperty(strPropName, dbText, "None")
        doc.Properties.Append prp            ' Append to collection.
        Resume
    Else                                        ' Unknown error.
        GetSummaryInfo = ""
        Resume GetSummary_Bye
    End IfFunction