File copy and rename in access

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

Guest

Hello all, and thanks in advance

I’m trying to copy a file then rename using VB in access. I looked at the
docmd.copyobject, but it looks like it is for objects within access.

First question is can it be done? If so how, I have tried the old DOS way;

copy file C:\BPS\Database\bps.mdb c:\

But it didn’t work

The steps in trying to complete are:

Copy BPS.mdb to other folder
Rename BPS.mdb to CopyBPS.mdb
Then copy again so that I can manually paste it to an FTP folder.

Also, this is a different database then the on the code is running in.
 
This will create a copy of the file:
FileCopy OriginalPathAndFileName, NewPathAndFileName

This will rename a file (and move it as well if OldPath is different from
NewPath):
Name OldPathAndFileName As NewPathAndFileName
 
Mark said:
Hello all, and thanks in advance

I'm trying to copy a file then rename using VB in access. I looked
at the docmd.copyobject, but it looks like it is for objects within
access.

First question is can it be done? If so how, I have tried the old
DOS way;

copy file C:\BPS\Database\bps.mdb c:\

But it didn't work

The steps in trying to complete are:

Copy BPS.mdb to other folder

FileCopy "C:\BPS\Database\bps.mdb", "c:\bps.mdb"
Rename BPS.mdb to CopyBPS.mdb

Which one, the original or the copy? If it was the copy, you could have
renamed it as part of the copy process:

FileCopy "C:\BPS\Database\bps.mdb", "c:\CopyBPS.mdb"

If you wanted to rename the original file, you could use the Name
statement:

Name "C:\BPS\Database\bps.mdb" As "C:\BPS\Database\CopyBPS.mdb"
Then copy again so that I can manually paste it to an FTP folder.

I don't follow you here. Please explain in more detail. Are you
talking now about copying it to the clipboard? If you know where you
want to copy it to, you can use FileCopy. If you really need to copy to
the clipboard, it's not so simple.
Also, this is a different database then the on the code is running in.

Good, then it will probably work, so long as that database isn't open.
 
Dirk,

Yes, I would like to copy it to the clipboard, or FTP it to a website.

Maybe I'm going about it wrong, here's what I'm trying to accomplish.

We have inventory on a website, and it resides in the BPS.mdb file.
Everyday I upload new BPS.mdb file to update inventory
I rename it, so that I can upload it fully without rewritting it, or the web
would be down while uploading.
Once on the web I rename BPS.mdb to BPS1.mdb. I then rename COPYBPS.mdb to
BPS.mdb and thenj we are back up.

I'm soon going to be leaving the company and was trying to make this
automatic within Access.

I guess if I could get access to FTP then rename would be better, but if not
then it would be nice to have it copy to the clipboad so the user then could
copy on over to the web.

PS thanks to you and Ken, that did get it where it copyied the file!
 
Mark said:
Dirk,

Yes, I would like to copy it to the clipboard, or FTP it to a website.

Maybe I'm going about it wrong, here's what I'm trying to accomplish.

We have inventory on a website, and it resides in the BPS.mdb file.
Everyday I upload new BPS.mdb file to update inventory
I rename it, so that I can upload it fully without rewritting it, or
the web would be down while uploading.
Once on the web I rename BPS.mdb to BPS1.mdb. I then rename
COPYBPS.mdb to BPS.mdb and thenj we are back up.

I'm soon going to be leaving the company and was trying to make this
automatic within Access.

I guess if I could get access to FTP then rename would be better, but
if not then it would be nice to have it copy to the clipboad so the
user then could copy on over to the web.

You can FTP from Access. One rough approach is to run the command-line
FTP utility, FTP.exe, that comes with Windows, passing it a script to
execute that does what you want. See the following link if you want to
go that route:

http://www.mvps.org/access/modules/mdl0015.htm

Another approach is to use the Internet Transfer Library developed by
Dev Ashish, downloadable from

http://www.mvps.org/access/modules/mdl0037.htm

The original version didn't support renaming a remote file, but I see
there's a beta version now that does. I've used the former, but not the
latter.

The advantage of using the library rather than the command-line utility
is that, with the library, you can catch and respond to errors. So I'd
prefer that, given a choice.
 
Back
Top