Solved

Close mdb database and delete it

Posted on 2002-03-22
2
175 Views
Last Modified: 2008-02-01
I am trying to close a database and delete the mdb file.  However, when I do this it does not delete the file because the file is still locked.  Using DAO, is there a way to check to see if the mdb is still locked and wait until it is ok to delete it or is there a better way to do this?

If Not (Dbs Is Nothing) Then
    Dbs.Close
    Set Dbs = Nothing
    Data1.Database.Close
    Data2.Database.Close
    DoEvents
End If
sFileSpec = ProjectPath & "\" & ProjectName & ".mdb"
If Dir(sFileSpec) <> vbNullString Then Kill sFileSpec
0
Comment
Question by:joesmow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
RichW earned 50 total points
ID: 6894682
Look for the .ldb file in the same directory as the .mdb file.  The .ldb file is the Access locking file.  It will have the same name as the db with the .ldb extension.

Another thing you could try would be to move the delete code out of the current procedure.  Once you declare a recordset in a procedure, and the scope of that procedure dies, the connection and recordset objects die with it.

Good luck.
0
 

Author Comment

by:joesmow
ID: 6913304
Thanks.  Using a different procedure to close the databases seems to work.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question