Solved

Close mdb database and delete it

Posted on 2002-03-22
2
164 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
2 Comments
 
LVL 4

Accepted Solution

by:
RichW earned 50 total points
Comment Utility
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
Comment Utility
Thanks.  Using a different procedure to close the databases seems to work.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now