Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Close mdb database and delete it

Posted on 2002-03-22
2
Medium Priority
?
189 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 200 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

636 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