Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would like to copy a series of files that begin with a specific date that has been selected from my form screen. I would like to add this to the end of a procedure that already runs from an Access command button. However immediately when I finish typing the command and move off the line of text I typed, the destination for the files is highlighted and I get an compile error "Expected: End of Statement"

    copy "N:\Files\" & Format(Forms!frmMenu!AbsDt, "mm-dd-yy") & "*.*" "H:\Backup\AbsenceFiles\"
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  2. #2
    Star Lounger
    Join Date
    Sep 2002
    Location
    Hastings, Sussex, England
    Posts
    67
    Thanks
    0
    Thanked 1 Time in 1 Post
    Judy,

    Not my area of expertise, but it looks as if you are trying to use a DOS command within VBA. When I've had to copy files in the past, I've set a variable to a FileSystemObject, e.g. Dim objFSO as FileSystemObject. Then, the methods such as objFSO.CopyFile become available.

    Hope this helps,

  3. #3
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    [quote name='JudyJones' post='793380' date='15-Sep-2009 08:07']I would like to copy a series of files that begin with a specific date that has been selected from my form screen. I would like to add this to the end of a procedure that already runs from an Access command button. However immediately when I finish typing the command and move off the line of text I typed, the destination for the files is highlighted and I get an compile error "Expected: End of Statement"

    copy "N:\Files\" & Format(Forms!frmMenu!AbsDt, "mm-dd-yy") & "*.*" "H:\Backup\AbsenceFiles\"[/quote]
    I believe in this case you want to use FileCopy rather than copy - see these posts by Hans - Copy File to Another Location and Wanting a List of Directories...
    Wendell

  4. #4
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your help. You got me on the right path. I had to keep playing with FileCopy to get it to work. There were 9 files and I tried to copy them using the asterisk as a wildcard to copy them using just one command line. That did not work for me so I inserted 9 commands one for each file I wanted to copy and then it worked just fine. One other thing that did not work was assuming that the command worked like the DOS command where you provide the path, foldername and filename in the source and then just the path and foldername in the destination. It did not work until I included the filename in the destination as well as the source.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

Posting Permissions

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