rename a file

J

Judy Ward

I want to rename and move a file from within the code of an Access form.

I am using the name command:
Name OldPathAndFileName As NewPathAndFileName

This works, but only if the NewPathAndFileName does not already exist. Is
there a command that will rename and move the file even if it already exists?

Thank you,
Judy Ward
 
M

Marshall Barton

Judy said:
I want to rename and move a file from within the code of an Access form.

I am using the name command:
Name OldPathAndFileName As NewPathAndFileName

This works, but only if the NewPathAndFileName does not already exist. Is
there a command that will rename and move the file even if it already exists?


Just KILL the file first. If it gives you an error about
file not existing, then use DoCmd.SetWarnings or error
trapping to ignore the error.
 
D

Douglas J Steele

An alternative to Marsh's suggestion is:

If Len(Dir(NewPathAndFileName)) > 0 Then
Kill NewPathAndFileName
End If
Name OldPathAndFileName As NewPathAndFileName
 

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