Solved

Access 2003 delete ntfs file from access macro

Posted on 2013-12-18
5
629 Views
Last Modified: 2013-12-23
I need to delete a network file from a network folder from an ACCESS 2003 macro or module
0
Comment
Question by:eyes59
5 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 39729047
From within VBA, it's nothing more then a simple:

 KILL "C:\.....\myFile.txt"

Be it a mapped network drive or local.   You also can use UNC naming:

 KILL "\\<server>\<share>\<path>\<file>"

 Jim.
0
 
LVL 38

Expert Comment

by:Jim P.
ID: 39729057
From a VBA module:
If Dir(FileName)<> "" Then
    Kill FileName
End If

Open in new window

0
 
LVL 26

Expert Comment

by:Nick67
ID: 39729781
Here's a little shim that uses the file dialog to let you select, confirm and kill a file.
The File Dialog requires a reference to Microsoft Office XX.0 Object library
(XX being 11 for A2003 -- although my machine runs A2003 and is now showing 12!)
The barest minimum I like is
Dim BuiltPath As String
BuiltPath = "Some valid path"
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(BuiltPath) Then
    fs.DeleteFile BuiltPath, True
End If

Open in new window

FileSystemObject is your friend
Murder.mdb
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 39736895
All of these will work except if security on the drive is too high -- in recent Windows versions, I have often had problems with deleting, moving or copying files in Windows 7 (especially on Drive C).
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

820 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