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

x
?
Solved

Delete a directory - Access 97

Posted on 2001-06-18
13
Medium Priority
?
218 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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 …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

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