Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2004
    Posts
    64

    Unanswered: copy file to another location

    From a command button what would be the code to copy a file from one location to another i.e copy c:\data\salesdata.mdb to e:\databackup\salesdata.mdb

    Peter

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Well - you could shell using xcopy or use File System Object.

    FSO approach: As I recall - there isn't a copy as such however you can rename (the name includes the path) and effectively move it. Or maybe there is a copy and that is the way you move things. Hmmm. (NOPE - checked Help and that's wrong too).

    Anyway - check out file system object in help. Once you've found it, look for the CopyFile method

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    VBA also has the no-effort
    FileCopy fromHere, toThere

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by izyrider
    VBA also has the no-effort
    FileCopy fromHere, toThere
    What possible, outlandish reason would you want to do that when you could set a reference to a library, declare and instantiate an object, use the method and then dispose?

    Code:
    FileCopy fromHere, toThere
    Vs (after setting reference)
    Code:
    Dim fso as FileSystemObject
    Set fso = New FileSystemObject
    fso.CopyFile fromHere, toThere
    Set fso = Nothing
    Over here we call it a no brainer


    Nice function Izy - everytime I think I have a use for fso you have one better.
    Last edited by pootle flump; 01-20-06 at 11:03.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    how about a class module in a remote library that late-binds to FSO.
    then a class provider function (as you helped me with a couple of days ago).
    check if in MDE or B
    ...and if in B
    run some api code to scan the disk, find your library and reference it
    then undocumented syscmd to make MDE
    delete the MDB
    develop some code to scrub the deleted MDB from the deleted folder
    ...and if in E
    run lockdown code

    i'm certain that with a little effort we could spread this thing out to 850 lines of code (plus documentation, of course).

    maybe 300 hours at $150.00/hour. yum yum

    you are so right pootle - FileCopy just isn't professional!

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Don't forget a few random calls to CAPICOM...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •