Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Importing multiple csv files (Access 2002)

    I need help with some code how to import about 20 csv files. I don't have the names so it should upload all files in a certain directory.

    Thanks

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Importing multiple csv files (Access 2002)

    Mario

    Are you just wanting to copy from one path to another ?
    or
    Trying to import into a table ?

    If you just want the first option.
    Can you supply Source Directory,Folder and Destination Directory,Folder.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Importing multiple csv files (Access 2002)

    I would like to automate the import of file csv into a table

    Thanks

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Importing multiple csv files (Access 2002)

    Mario.

    Is this a "New" table , or an existing table ?

    You should check out the :-

    "DoCmd.TransferText" command.

    Importing to a new table is quite straight forward, where importing to an existing table isn't.
    On the latter, the Fields must be the same for Source and destination.

  5. #5
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Importing multiple csv files (Access 2002)

    The import will be a new table for all the CSV files. My code is al follows:

    DoCmd.TransferText acImportDelim, "SumSpecs", "InvoiceSummaries", "C:308A0000060T-SUM.txt", False, ""

    How will I write the code to populate the filename with all the txt files in a folder in a loop?

    Thanks

    Mario

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Importing multiple csv files (Access 2002)

    Then you'll need something like the following, Edit it to suit your needs:


    Dim FileName As String
    Dim FolderName As String

    FolderName = "C:YourImports"

    FileName = Dir(FolderName & "*.csv")

    While FileName <> ""
    DoCmd.TransferText acImportDelim, "file import specification", "tablename", FolderName & "" & FileName
    FileName = Dir()
    Wend

Posting Permissions

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