Solved

Delete a directory - Access 97

Posted on 2001-06-18
13
214 Views
Last Modified: 2008-02-26
Hi all,

1 of my procedures creates a temp directory (c:\TempImportDb) in which I put a copy of empty tables, import some data, and do some stuff. At the end I want to delete the temp database (kill statement which works fine) and then delete the temp directory (RmDir which does not work at all). I do:

     Dim dbPathDir As String
     dbPathDir = "C:\TempImportDb\"

     If fIsFileDIR("C:\TempImportDb\", vbDirectory) = True Then
              RmDir dbPathDir
     End If

I am getting error 75, "Path/File access error". Seems like access thinks that the file is still being used. I also tried the ChDir command befor the RmDir but no joy. Any ideas?

Any advice would be appreciated

Dave
0
Comment
Question by:dcobau
[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
  • 3
  • 2
  • 2
  • +2
13 Comments
 
LVL 5

Expert Comment

by:gbaren
ID: 6204860
Try ChDir to another directory before deleting it.
0
 
LVL 6

Expert Comment

by:cjswimmer
ID: 6204943
If there are any files left in the directory, the kill statement will fail.  If you are opening an Access db file in that dir, it creates an ldb file while it is open.  The ldb file might not be deleted by the time you try to kill the dir.  Try testing for dir(C:\TempImportDb\*.*) in a loop and use a Kill function for everything it finds until the Dir returns "".  You might want to trap for errors too in case Access is still closing and you can't delete the ldb file.  hope this helps.

cjswimmer
0
 
LVL 2

Expert Comment

by:jack49a
ID: 6206333
Add a reference to Microsoft Scripting Runtime library and delete using the FileSystemObject. You can also use the FileSystemObject to move or delete files.  I use it with Access 2000,  Don't think it works with 97 though.

Jack

For example

Sub TempFolder()
Dim objFS As New Scripting.FileSystemObject
Dim strFolder As String

strFolder = "C:\TempImportDb\"

If objFS.FolderExists(strFolder) Then
  objFS.DeleteFolder (strFolder)
   MsgBox "Folder " & strFolder & " deleted"
   Else
   MsgBox "Folder " & strFolder & " does not exist"
 End If


Set objFS = Nothing
End Sub
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 2

Expert Comment

by:jack49a
ID: 6206366
According to  'VB and VBA in a Nutshell' this FileSystemObject.DeleteFolder method will delete folders and contents (files and subdirectories). (Permanent delete not recycle bin)  Can set option to force it to delete read only files if needed.
Jack
0
 

Author Comment

by:dcobau
ID: 6208613
Well, thanks everybody for your comments. I have resolved my problem by deleting the directory (if it exhist)from another db. db1 opens db2 where I create the temp dir and where I wanted to delete it after doing things. Now I check and delete it from db1 before opening db2.

Thanks again

Dave
0
 
LVL 6

Expert Comment

by:cjswimmer
ID: 6210153
If the problem is resolved then you need to either delete the question if you discovered the solution completely on your own or award the points to one of the experts.  Did any of the posts in this thread contribute to your solution?  
0
 

Author Comment

by:dcobau
ID: 6212410
hi ciswimmer,

I worked out a solution by myself, so I guess I need to delete the question. How do I do that?

Dave
0
 
LVL 6

Expert Comment

by:cjswimmer
ID: 6213948
It looks like you've got 6 other questions that are in some sort of limbo from the past year or so.  You should revisit those questions and either delete them if the problem was never solved, continue the discussion, or award the points to the closest solution.  Experts who examine a question owner's profile may be less likely to participate in offering a solution if they see that you do not follow through on finishing the session.  Just a suggestion.

cjswimmer
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 6737800
Question will be placed in PAQ.

ComTech
CS Admin @ EE
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

707 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