Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2006
    Posts
    1

    Unanswered: Move File Question

    I have a bit of code that I found to import multiple csv files into my access table, the problem with this is that it deletes the source file.

    Can someone help me with the code to move a copy of the file to a different directory instead of destroying the source?

    I have pasted the code below. Yes I am relatively new to vba and I did search before I posted a thread.

    Any help is greatly appreciated.
    Thanks,
    Technyne

    Private Sub Import_Click()
    Dim strfile As String
    ChDir ("C:\Path")
    strfile = Dir("DB*.csv*")
    Do While Len(strfile) > 0
    DoCmd.TransferText acImportDelim, "DB", "DB", "C:Path" & strfile, True

    Kill "C:\Path" & strfile
    strfile = Dir


    Loop
    End Sub

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    remove the "Kill" line.

    ProTip: Don't run code that deletes files if you don't understand what it does, that could have been extremely dangerous.... just sayin...
    oh yeah... documentation... I have heard of that.

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

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by Teddy
    ProTip: Don't run code that deletes files if you don't understand what it does, that could have been extremely dangerous.... just sayin...
    Lol - especially if the name is something so emotive. Even after all these years the term Kill just seems far too aggressive to me. I always feel compelled to use the more compassionate FileSystemObject.DeleteFile method.

    Anyhoo - look up FileCopy in Access help. Confusingly, you could also use CopyFile as part of the aforementioned FileSystemObject but that last line probably just muddies the waters.....

    HTH

    EDIT - BTW - welcome to the forum
    Last edited by pootle flump; 02-24-06 at 06:45.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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