Sure, here's an example of Creating an Access DB at runtime using the DAO Objects:
Code:
Private Sub Command1_Click()
Dim oWork As Workspace
Dim oDatabase As Database
Dim oTable As TableDef
Dim oField As Field
Set oWork = Workspaces(0)
'Create an Empty Database
Set oDatabase = oWork.CreateDatabase("C:\NewDB.mdb", dbLangGeneral)
'Create a Table Object
Set oTable = oDatabase.CreateTableDef("Table1")
'Create a Field Object
Set oField = oTable.CreateField("Field1", dbText, 20)
'Add the Field to the Table Object
oTable.Fields.Append oField
'Add the Table Object to the Database
oDatabase.TableDefs.Append oTable
'All Done, Close and Release the Objects
oDatabase.Close
oWork.Close
Set oField = Nothing
Set oTable = Nothing
Set oDatabase = Nothing
Set oWork = Nothing
MsgBox "Database Created"
End Sub
Thanks for the reply, but I have run into another problem. I'm using VB 6 Learning Edition, and it doesn't seem to recognize Workspace, Database, TableDef, and Field as valid variable types. Is there anyway to get around this, or will I just need to upgrade.