Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting a file from access using vba 1

Status
Not open for further replies.

GShen

MIS
Sep 26, 2002
561
US
I am creating a report using docmd.OutputTo as part of the code I am running in an EVENT. I need to delete the file after I am done with this routine. The file is on my local hard drive (c:).
I was reading something about file system object. delete file but there were no examples.
Anybody have an example?
 
The following example should delete a file if you provide the full path and filename in place of strFileSpec
Code:
Sub FileDelete()
   Dim fso
   Set fso = CreateObject("Scripting.FileSystemObject")
   fso.DeleteFile (strFileSpec)
   Set fso = Nothing
End Sub
You can include a second optional boolean argument, which if True will delete readonly files and if false (the default) will not.

A.C.
 
acron or anyone else who is knowledgeable in this area,
Hi. Need your help again. Everything works great. Have another problem. Need to be able to delete files within a certain date range. Can I somehow obtain the properties of the file and then loop thru and decide which ones I want to delete? I am a little concerned with just playing with this because I do not want to blow away an entire drive. Are these parameters anyplace where I can read them?
Thanks for the tip last time. Hoping you can enlighten me again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top