Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is Access command to copy/move file 2

Status
Not open for further replies.

WantsToLearn

Programmer
Feb 15, 2003
147
US
How do I move or copy a file selected via the Windows file browser from one folder to another (eg as if I did a ctl+c and ctl+v while in the browser)?

Thank you!
 
Same as before. The Windows Explorer has nothing to do with Access. You probably need to be out of the database prior to trying to more the files. Access databases consist of 1-2 files and possibly a workgroup only.

-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
I have found 2 ways to copy/move files from one place to another.

The first is filecopy. This will only copy a file from one location to another. To make it look like a move, you have to use the 'kill' command to delete the original.

The syntax for filecopy is:
Code:
filecopy [original file path], [new file path]
kill [original file path] (if you want to simulate move)
the other is 'name'... this syntax is:
Code:
name [original file path] as [new file path]
this will move the file to the new file path, or just rename it if the path is the same, but the filename is different.

Notes: the [original file path] and [new file path] containes the entire path of the file, as well as the file name.

Also.. I know that this works in Access97... and I think I've got a 2k database that I have this in, but I don't use 2k much (only at home). We are moving to 2k at work soon, though, so I'll see if it works then.

GComyn
 
The original question did not concern VBA but 'Windows File browser' which would be Windows Explorer. There are a few ways to do this from within code including the FileSystemObject which helps verify the .FolderExists or the .FileExists before taking any action to .CopyFile, .MoveFile, or .MoveFolder. These are only a representative set of the methods for FileSystemObject.


-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
Thanks to both of you. I was indeed trying to do this from within Access so the above ideas are very welcome. Sorry for the lack of clarity in the original post.

 
Good ways. Just a note though, I do not believe the FSO object is available in Access 97, only 2k. Although I may be incorrect, and If I am please tell me how to link it.. :)


Jeremy
WZ
 
In access 97, you reference the Microsoft Scripting Runtime (scrrun.dll). It is located in the c:\windows\system\ directed on my win98 computer.

GComyn
 
Actually the FileSystemObject has nothing to do with Access as it is a separate .DLL which is referenced from Access. You can then use it as if it were an implicit Access function. This is no different than the was VBA, DAO, and ADO are used within Access.

' Set reference to 'Windows Scripting Runtime"

Dim fso As FileSystemObject
Set fso As New FileSystemObject
fso.FileExists("FileYouAreChecking")


-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top