CreateDatabase Method Example

This example uses CreateDatabase to create a new, encrypted Database object.

Sub CreateDatabaseX()

    Dim wrkDefault As Workspace
    Dim dbsNew As DATABASE
    Dim prpLoop As Property

    ' Get default Workspace.
    Set wrkDefault = DBEngine.Workspaces(0)

    ' Make sure there isn't already a file with the name of 
    ' the new database.
    If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"

    ' Create a new encrypted database with the specified 
    ' collating order.
    Set dbsNew = wrkDefault.CreateDatabase("NewDB.mdb", _
        dbLangGeneral, dbEncrypt)

    With dbsNew
        Debug.Print "Properties of " & .Name
        ' Enumerate the Properties collection of the new 
        ' Database object.
        For Each prpLoop In .Properties
            If prpLoop <> "" Then Debug.Print "  " & _
                prpLoop.Name & " = " & prpLoop
        Next prpLoop
    End With

    dbsNew.Close

End Sub