CreateDatabase Function (Professional Edition Only)
See Also Example
Description
Creates a Microsoft Access database, and returns a Database object that is open for exclusive read/write access.
Syntax
Set dbobject = CreateDatabase( dbname [, locale [, options ]] )
Remarks
The CreateDatabase function has these parts:
Part Description
dbobject A Database object variable.
dbname A string expression 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:
\\MYSERVER\MYSHARE\MYDIR\MYDB
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 Long 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_NORWDAN Norway.
DB_LANG_ICELANDIC Iceland.
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.
Help:
And Operator
Close Method
CompactDatabase Statement
Exclusive Property
OpenDatabase Function
Refresh Method
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)
...