Results 1 to 4 of 4
  1. #1
    dumbledown is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    46

    Smile link tables using vba

    Hi,

    I have an n number of csv files in a folder that I want to link automatically to an access 2007 database. They are all named in the format file_n.csv, and the value n will change from use to use.

    So we have files:
    c:\folder\file_1.csv
    c:\folder\file_2.csv
    c:\folder\file_3.csv
    -
    -
    c:\folder\file_n.csv

    Does anyone know what code I need to link all of these files as tables?


    Many thanks
    Hugh

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Google: VBA link csv

    Here is one
    http://social.msdn.microsoft.com/For...7-0233661ec221

    You would need loop code that dynamically references the csv file name. Need to know how many files in the folder. You can have the number of files as input parameter or find code that would determine how many files are in the source folder.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    dumbledown is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    46
    Thanks June 7,
    That looks just the thing.
    I already have code that works out the value n, so do you know how the loop would work?
    I'm sure I can work it out, but I'm a beginner at VBA.
    Thanks again!!

  4. #4
    dumbledown is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    46
    Got loop all running now.
    Thanks again for the code, it worked perfectly!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Link tables
    By compooper in forum Import/Export Data
    Replies: 2
    Last Post: 06-23-2011, 07:08 PM
  2. Trying to Link tables
    By brandonze in forum Access
    Replies: 1
    Last Post: 05-19-2011, 11:03 PM
  3. how to link 3 tables?
    By handsome1855 in forum Access
    Replies: 1
    Last Post: 03-10-2011, 09:25 AM
  4. One-way link between tables
    By Mikele di Sagitter in forum Database Design
    Replies: 1
    Last Post: 07-23-2010, 08:26 AM
  5. Best way to link tables together?
    By marleyuk in forum Access
    Replies: 1
    Last Post: 06-07-2009, 08:44 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums