Solved

Close mdb database and delete it

Posted on 2002-03-22
2
178 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…

728 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