Delete file after import from directory c:\abc.txt

V

Vince

Hi,

Does anyone have a code for my button on click to run a
macro that deletes abc.txt file?

Please and thank you,

Newbie..

Vince
 
D

Dirk Goldgar

Vince said:
Hi,

Does anyone have a code for my button on click to run a
macro that deletes abc.txt file?

Please and thank you,

Newbie..

Vince

I may be wrong, but I don't think you can delete a file using a macro
alone. I think you have to use VBA to do it. The VBA code would be

Kill "c:\abc.txt"

So you could set your button's OnClick property to "[Event Procedure]"
and create this procedure (named as if your button were named
"Command1":

Private Sub Command1_Click()

Kill "c:\abc.txt"

End Sub

If your button has to do something else, finishing up with deleting the
file, then the best way to do it would be to write the whole process as
a VBA procedure, rather than using the very limited macro language. Let
me know if you need help with this.
 
K

Ken Snell

Dirk is correct. You cannot delete a file directly by a macro action. You
must use VBA.

--
Ken Snell
<MS ACCESS MVP>

Dirk Goldgar said:
Vince said:
Hi,

Does anyone have a code for my button on click to run a
macro that deletes abc.txt file?

Please and thank you,

Newbie..

Vince

I may be wrong, but I don't think you can delete a file using a macro
alone. I think you have to use VBA to do it. The VBA code would be

Kill "c:\abc.txt"

So you could set your button's OnClick property to "[Event Procedure]"
and create this procedure (named as if your button were named
"Command1":

Private Sub Command1_Click()

Kill "c:\abc.txt"

End Sub

If your button has to do something else, finishing up with deleting the
file, then the best way to do it would be to write the whole process as
a VBA procedure, rather than using the very limited macro language. Let
me know if you need help with this.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top