|
-
August 12th, 2001, 02:11 PM
#1
Creating a new Access DB
Can anyone tell me how to generate a brand new MS Access Database from within VB? Thanks...
-
August 13th, 2001, 05:28 AM
#2
Re: Creating a new Access DB
Call this routine. (I copy it from the MSDN library, this is not my sample)
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
-
August 13th, 2001, 06:50 AM
#3
Re: Creating a new Access DB
Create database using ADO
Make sure you have a reference set to the ADOX object library then use the following code.
Dim objCatalog as ADOX.Catalog
Set objCatalog = New ADOX.Catalog
objCatalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\mynewdb.mdb"
Iouri Boutchkine
[email protected]
-
August 13th, 2001, 10:28 AM
#4
Re: Creating a new Access DB
Dim appAccess as Access.Application
set appAccess = new Access.Application
appAccess.NewCurrentDatabase "C:\WINDOWS\Desktop\MyDB.mdb"
set appAccess = nothing
You will need to add Reference to "Microsoft Access 9.0 Object Library" (ACCESS 2000)
RF
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|