Renaming a Text File in Access 2002 using VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am converting an 97 Application to 2002. The 97 appln
has a code as,

OldName = "E:\Credinq\cma monthly\inquiry.txt":
Newname = "E:\Credinq\cma monthly\inquiry2.txt "
Name OldName As Newname


This is not working in 2002. The error "File Not Found"
comes up. I checked the value for Oldname using debugger
and it comes up correct and the file does exist.

Is it that 'name' method does not work in 2002? In that
case what is the equivalent in 2002?If name does work any
idea what the problem is?

Thanks.
 
Hi, Add Reference "Microsoft Scripting Runtime

Now write
Dim fso As New Scripting.FileSystemObjec
now try using fso.<various functions are available>.

Hope this help
 
Here are two methods for copying a file in Access 2000.
Maybe they will work in 2002

Private Sub Command10_Click()
FileCopy "sourcefile", "destinationfile"
End Sub

or if the file is in use try

Private Sub Command10_Click()
Dim fso As Object
Dim boverwrite As Boolean

Set fso = CreateObject("Scripting.fileSystemObject")
fso.copyfile "sourcefile", "sourcefile"

Set fso = Nothing

End Sub


Jim
 
Name works fine in Access 2002.

The problem may be the space at the end of the NewName. Try without the
space.
 
Back
Top