p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access VBA (http://p2p.wrox.com/forumdisplay.php?f=80)
-   -   Delete files with command button (http://p2p.wrox.com/showthread.php?t=77494)

RodM December 18th, 2009 10:25 AM

Delete files with command button
I created a personal household inventory database for homeowner's insurance purposes. Each record contains data related to a household item such as a TV, table, etc. Each item has two associated .jpg files which show a photo of the item and related documents. These .jpg files are in the same folder as the database .mdb file. Each record contains an ItemNumber field and I assign each household item a unique number such as AP001. Each .jpg file is similarly named such as AP001.jpg and AP001-Doc.jpg. I placed a command button on my form to delete records no longer needed but must manually delete the associated .jpg files. When I click my command button to delete a record I want to automatically delete the .jpg files as well. Any help would be greatly appreciated.

gbianchi December 28th, 2009 09:49 AM

Hi there..

Use the command Kill (Kill "C:\Your_Folder\Yourfile")

RodM December 30th, 2009 09:02 AM

Delete Files with Command Button
Thank you for your reply. This is what I needed.

ayazhoda March 2nd, 2010 09:48 AM

This will not happened if your file is lock by some application

SerranoG March 5th, 2010 09:08 AM

Rod, just a thought.

If you ever need to get any of those back, you will be messed up by deleting them. If you ever decide you don't need a record anymore, don't delete it. Instead, tag it as inactive. Have your form filiter so that the default is it only shows active records. Later, if you change your mind, you can filter for inactive records and untag the desired one. All will be there.

ayazhoda March 5th, 2010 09:55 AM

Just to add few more bit as additional review

1. Its better to send them recycle bin first as kill will delete file for ever ( may be user click wrong button and wants to recover later on.

2. Make sure file must not be used by someone else by the time you are deleteing it.

3. You can set a bool variable to show them or not, insted of deleting them

4. What would happen in 6 months time you need that file again

All times are GMT -4. The time now is 11:21 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.