Link to home
Start Free TrialLog in
Avatar of joesmow
joesmow

asked on

Close mdb database and delete it

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
ASKER CERTIFIED SOLUTION
Avatar of RichW
RichW
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joesmow
joesmow

ASKER

Thanks.  Using a different procedure to close the databases seems to work.