Hi.
You probably already did this when you created the new MDB file, but if not,
then you need to set a reference to the DAO library. Then you can paste in
code from the following example:
Private Sub OKBtn_Click()
On Error GoTo ErrHandler
Dim accApp As New Access.Application
Dim db As DAO.Database
Set db = CreateDatabase("C:\Test\NewDB.mdb", dbLangGeneral)
'-------------------------------------------------------------------------
' Do whatever you need to do in your new database . . .
'-------------------------------------------------------------------------
db.Close
DoEvents ' Give OS chance to save file before accessing it.
'-------------------------------------------------------------------------
' Connect to the new database using an instance of
' Access.
'-------------------------------------------------------------------------
accApp.OpenCurrentDatabase "C:\Test\NewDB.mdb", True
accApp.SetOption "Track Name AutoCorrect Info", False
accApp.SetOption "Perform Name AutoCorrect", False
accApp.SetOption "Auto Compact", True
CleanUp:
Set db = Nothing
Set accApp = Nothing
Exit Sub
ErrHandler:
MsgBox "Error in OKBtn_Click( ) in " & Me.Name & " form." & _
vbCrLf & vbCrLf & Err.Number & vbCrLf & Err.Description
GoTo CleanUp
End Sub
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts, so that all
may benefit by filtering on "Answered questions" and quickly finding the
right answers to similar questions. Remember that the best answers are often
given to those who have a history of rewarding the contributors who have
taken the time to answer questions correctly.