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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code for deleting a file on hard drive

Status
Not open for further replies.

steve728

Programmer
Mar 16, 2003
536
0
0
US
Please give me a sample of the vba code I would use to delete a file located at C:\Program\Data\repair.txt.

I don't want to use the interface. I want delete from code.

Thank you!

Steve
 
Also,please, how do I delete a table from my mdb using vba code.

Thanks,

STeve
 
In reply to your second question: are you in an mdb or an adp? If you are in an adp, then you use the SQL command "Drop Table" where table is the name of the table you want to delete. Using the fully qualified name of the table is the best course to follow.
 
To Delete a File from a directory...

dim strFile as String
strFile = "C:\Program\Data\repair.txt"

If Dir(StrFile) Then 'Check to see if file exists
Kill strFile
End If

Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top