Kill

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

According to HELP on the Kill function, no error should
occur if the file to be deleted doesn't exist. Yet, I do get
a runtime error when that situation arises. Am I missing
something here?
Thanks,
Bill
 
Bill said:
According to HELP on the Kill function, no error should
occur if the file to be deleted doesn't exist. Yet, I do get
a runtime error when that situation arises. Am I missing
something here?
Thanks,
Bill

Bill, where do you see this statement in the help file? And in what
version of Access? It doesn't say that in my Access 2002 VB help file.
 
Bill said:
According to HELP on the Kill function, no error should
occur if the file to be deleted doesn't exist. Yet, I do get
a runtime error when that situation arises. Am I missing
something here?
Thanks,
Bill

Unless it was changed in later versions, the help file in Access 97 does not
indicate that no error will occur.
 
Sorry guys, I must have stretched the implication too much.
The HELP comment in A2000: "An error occurs if you try
to use Kill to delete an open file." by implication suggests
that it is the only situation, ignoring for the moment the MAC,
an error is raised.

Is there a better way to deal with non-existing files using Kill
than to trap the runtime error?

Bill
 
You could use the Dir function to see if the file exists:

If Dir("C:\MyFolder\MyFile.ext") <> "" Then Kill "C:\MyFolder\MyFile.ext"
 
Hi Ken,
Haven't chatted with you for a long time. Anyway, I think I searched
for everything but "Dir"... hahaha!
Thanks,
Bill
 
You can check to see if the file exists before using Kill.

Easy way: http://support.microsoft.com/default.aspx?scid=kb;en-us;175923

Slightly more complicated way if needed:
http://support.microsoft.com/default.aspx?scid=kb;en-us;168519

Good luck.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
Bill said:
Sorry guys, I must have stretched the implication too much.
The HELP comment in A2000: "An error occurs if you try
to use Kill to delete an open file." by implication suggests
that it is the only situation, ignoring for the moment the MAC,
an error is raised.

Let that be a lesson to you about inferring things from what the help
file *doesn't* say. said:
Is there a better way to deal with non-existing files using Kill
than to trap the runtime error?

Although Ken and Sco have pointed out ways to check if the file exists,
I'd be more inclined just to trap the error.
 
Indeed!
Thanks,
Bill




Dirk Goldgar said:
Let that be a lesson to you about inferring things from what the help


Although Ken and Sco have pointed out ways to check if the file exists,
I'd be more inclined just to trap the error.

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

(please reply to the newsgroup)
 
Back
Top