Create tmp mdb problem

B

Bryan Hughes

Hello,

I am having a problem with the deleting a temp mdb.

I am using the code from Tony Towes' website
http://www.granite.ab.ca/access/temptables.htm to create and delete the mdb.

The temp mdb is created just fine, but I keep getting error code 70
("Permission Denied") when I try and delete it.

Even if I just create the mdb and not create and link any tables to it, I
still get the error code.

What is the porblem

This is the code to create the mdb
' Get default Workspace.
Set wrkDefault = DBEngine.Workspaces(0)
strTempDatabase = Left(CurrentDb.Name, Len(CurrentDb.Name) - 4) &
"_temp.mdb"

' Make sure there isn't already a file with the name of
' the new database.

If Dir(strTempDatabase) <> "" Then Kill strTempDatabase

'Create a new temp database
Set dbsTemp = wrkDefault.CreateDatabase(strTempDatabase, dbLangGeneral)

This is the code to delete the mdb

' Delete the temp mdb
Set wrkDefault = DBEngine.Workspaces(0)
strTempDatabase = Left(CurrentDb.Name, Len(CurrentDb.Name) - 4) &
"_temp.mdb"
Kill (strTempDatabase)

What did I miss?

-TFTH
Bryan
 
M

Marshall Barton

Bryan said:
I am having a problem with the deleting a temp mdb.

I am using the code from Tony Towes' website
http://www.granite.ab.ca/access/temptables.htm to create and delete the mdb.

The temp mdb is created just fine, but I keep getting error code 70
("Permission Denied") when I try and delete it.

Even if I just create the mdb and not create and link any tables to it, I
still get the error code.

What is the porblem

This is the code to create the mdb
' Get default Workspace.
Set wrkDefault = DBEngine.Workspaces(0)
strTempDatabase = Left(CurrentDb.Name, Len(CurrentDb.Name) - 4) &
"_temp.mdb"

' Make sure there isn't already a file with the name of
' the new database.

If Dir(strTempDatabase) <> "" Then Kill strTempDatabase

'Create a new temp database
Set dbsTemp = wrkDefault.CreateDatabase(strTempDatabase, dbLangGeneral)

This is the code to delete the mdb

' Delete the temp mdb
Set wrkDefault = DBEngine.Workspaces(0)
strTempDatabase = Left(CurrentDb.Name, Len(CurrentDb.Name) - 4) &
"_temp.mdb"
Kill (strTempDatabase)

What did I miss?


Also, make sure that you have Closed the dbsTemp object
before trying to delete the file.
 
B

Bryan Hughes

Marshall,

Thanks for the help. That did the trick. I closed dbsTemp and Set dbsTemp
= Nothing
Then it worked fine.

-TFTH
Bryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top