Create a database programatically

O

OriginalStealth

Form1 has cmdNewDbBtn and cboHQ. The On click event of
the cmdNewDbBtn needs to:

1. Create a new database.
2. The new db name needs to be the cboHQ.value. The new
db will have only one table in it called table1 which
will need to be exported and I can do that.

cboHQ.value = Atlanta

Thanks in advance!
OS
 
A

Allen Browne

This example shows how to create a database using the DAO library.
It also demonstrates how ot turn off the properties that are likely to
corrupt the database.

Sub CreateDb()
Dim dbNew As DAO.Database
Dim prp As DAO.Property
Dim strFile As String

strFile = "C:\" & Me.cboHQ.Value
Set dbNew = DBEngine(0).CreateDatabase(strFile, dbLangGeneral)

With dbNew
Set prp = .CreateProperty("Perform Name AutoCorrect", dbLong, 0)
.Properties.Append prp
Set prp = .CreateProperty("Track Name AutoCorrect Info", _
dbLong, 0)
.Properties.Append prp
End With

dbNew.Close
Set prp = Nothing
Set dbNew = Nothing
Debug.Print "Created " & strFile
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top