Solved

Delete a directory - Access 97

Posted on 2001-06-18
13
209 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
  • 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
 
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

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.

Question has a verified solution.

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

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

911 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

23 Experts available now in Live!

Get 1:1 Help Now