tags:

views:

178

answers:

2

i want to create a number of databases in ms-access using a code or any option of ms-access, but i want delete databases also. Please help me

+3  A: 

You could have an empty database named "db1.mdb", and then add this code inside a module in another Access database:

  Set fso = CreateObject("scripting.filesystemobject")
  fso.CopyFile "c:\db.mdb", "c:\db_copy1.mdb", True
  fso.CopyFile "c:\db.mdb", "c:\db_copy2.mdb", True
  fso.CopyFile "c:\db.mdb", "c:\db_copy3.mdb", True
  fso.DeleteFile "c:\db.mdb"
Berzerk
+1  A: 

To create an Access database from Access interface:

createDatabase "myNewMDB.mdb", dbLangGeneral

To delete a database:

kill "myNewMDB.mdb"

It works without initial mdb file or extra dlls

for multiple databases

public Function createDeleteDatabase(howManyDatabases as integer) as boolean

''output is by default False
createDeleteDatabase = False

on error goto createDeleteDatabase_Error

Dim i as integer
For i = 1 to howManyDatabases
    createDatabase "myMDBNumber_" & str(i,0) & ".mdb", dbLangGeneral
Next i
For i = 1 to howManyDatabases
    kill "myMDBNumber_" & str(i,0) & ".mdb"
Next i

''if no errors in the fonction, set the output to True
createDeleteDatabase = True

Exit function
createDeleteDatabase_Error:
'' your error treatment
End function
Philippe Grondier