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
我想使用代码或ms-access的任何选项在ms-access中创建许多数据库,但我也想要删除数据库。请帮我
2 个解决方案
#1
3
You could have an empty database named "db1.mdb", and then add this code inside a module in another Access database:
您可以拥有一个名为“db1.mdb”的空数据库,然后将此代码添加到另一个Access数据库的模块中:
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"
#2
1
To create an Access database from Access interface:
要从Access界面创建Access数据库:
createDatabase "myNewMDB.mdb", dbLangGeneral
To delete a database:
要删除数据库:
kill "myNewMDB.mdb"
It works without initial mdb file or extra dlls
它没有初始mdb文件或额外的dll
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
#1
3
You could have an empty database named "db1.mdb", and then add this code inside a module in another Access database:
您可以拥有一个名为“db1.mdb”的空数据库,然后将此代码添加到另一个Access数据库的模块中:
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"
#2
1
To create an Access database from Access interface:
要从Access界面创建Access数据库:
createDatabase "myNewMDB.mdb", dbLangGeneral
To delete a database:
要删除数据库:
kill "myNewMDB.mdb"
It works without initial mdb file or extra dlls
它没有初始mdb文件或额外的dll
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