CreateDatabase Function (Professional Edition Only)

See AlsoG8N3LO                 Example1Y4OZCY>Low


Creates a Microsoft Access database, and returns a Database object that is open for exclusive read/write access.


Set dbobject = CreateDatabase( dbname [, locale [, options ]] )


The CreateDatabase function has these parts:

Part                 Description


dbobject           A Database object variable.

dbname            A string expression1330R89 for the name of your new database.  It can be a fully qualified path, such as C:\MYDB.MDB.  The file-name extension, if applicable, is required.  If your network supports it, you can also specify a fully qualified network path, such as:

locale               A string expression specifying the language information for creating the database.  Although not required, an incorrect information in this part will cause a run time error.  See the table below for locale settings.

options             A Long1DDU1E5 numeric value indicating one or more options.  See the table, below.


You can supply one of the following symbolic constants (from DATACONS.TXT) in the locale part:

Constant                         Description


DB_LANG_GENERAL       English, German, French.

DB_LANG_SPANISH        Spanish, Italian.

DB_LANG_DUTCH           Dutch.

DB_LANG_SWEDFIN       Sweden.



DB_LANG_NORDIC         Nordic countries (Microsoft Access 1.0 only).


You can supply one or more of the following values or symbolic constants (from DATACONS.TXT) in the options part:

Constant                           Value        Definition


DB_ENCRYPT                      2            Encrypt the database.  To decrypt a database, use the CompactDatabase statement.

DB_VERSION10                    1            Create a Microsoft Access 1.0 database.


You can indicate more than one option by adding values together.

The CreateDatabase function opens the new database for exclusive access.  To open it for multiuser access you can use the Close method on the database, then open it again with the OpenDatabase function.

If the database file already exists, an error occurs.

See Also


And OperatorLANAND

Close MethodPMJS3T

CompactDatabase Statement4TLG0M8

Exclusive PropertyCLKVGH

OpenDatabase Function18AIK1S

Refresh Method3SMNZGP


Data Access Guide:

Chapter 2, "Database Management Using Visual Basic"

CreateDatabase Function Example

The example creates a new database named MYDB.MDB.

Dim CurDB As Database
' Use general locale setting from DATACONS.TXT.
Set CurDB = CreateDatabase("C:\MYDB.MDB", DB_LANG_GENERAL, DB_VERSION10)