Copy Files

Adi
07-02-2001, 11:00 AM
hi,

Does anyone know how to copy a file from a specific location and name to a different location and different name from an Access Database?

e.g. I am in an Access Database and i have a file called "MyFile.xls" saved in 'C:\My Documents' and i need to save a backup of this file into the network - H:\Pens\ on a different Name - "MyFileBackup (Date).xls".

I would know how to implement the Date side of this little problem, but i have no idea of how to copy a file using VBA.

Also, is there a way you can compact a different database at a different location from an Access database i am working on?
is there a way i can maybe map a network drive from the access database?

Help!

thax

Adi

<*Take my future, past, it's fine, but now is mine*> "K's Choice"

kcwallace
07-02-2001, 05:47 PM
filecopy "C:\My Documents\MyFile.xls","H:\Pens\MyFileBackup "& date & ".xls"

Adi
07-03-2001, 02:25 AM
That's Brilliant, thank you!

Of course, it doesn't work unless I format the date function to a more readable version like

format(date,"yymmdd")

otherwise it will come up with "Path Not Found" since the date has this format - dd\mm\yy

Unfortunately, this line doesn't check to see if the file already exists or not. How can I check that so that I don't overwrite the existing file?

Also, do you know how to Compact a different database from an access database?

thx

Adi

<*I'm so aware of where I am, but I don't know where that is*> "K's Choice"

Adi
07-03-2001, 03:22 AM
P.S.

is it also possible to put a Progress Bar to indicate that the file is being copied and has finished.

Bigpapou
07-03-2001, 11:18 AM
You could use the "DBEngine.CompactDatabase olddb, newdb, locale, options, password" function

Adi
07-05-2001, 02:14 AM
thanks! that worked great!

would you also know if i could find out if a certain file already exists in a location b4 i copy over it?

thanx

Adi

Bigpapou
07-06-2001, 07:00 AM
Sorry man... I haven't figured out that one yet!
I'll tell you what... If I figure it out I'll E-mail you and if you find out just E-mail me.

kcwallace
07-06-2001, 10:19 AM
if dir("file path")="" then
filecopy source,destination
else
msgbox "file already exists"
end if


"" means that the file does not exist. If you want to see if a file exists then just replace the = with a <>.

Adi
07-09-2001, 10:19 AM
WOW. that's great. Definitely did the trick.

thanx m8.

Adi.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum