Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Bristol, Avon, England
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Import automation (2000 SR1)

    Daily I receive a data file in .txt format from a client. I import this into an Access database and use a previously save import specification. Which work fine.
    Can I put some code behind a button that will do this automatically for me?
    If so what is it?

    I have tried using a linked table instead of importing but when I try using an update query I get an error saying 'Updating Data in a linked table is not supported by this ISAM'. Which is why I am asking about importing rather than linking.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import automation (2000 SR1)

    You can use DoCmd.TransferText to import a text file. Example:

    DoCmd.TransferText TransferType:=acImportFixed, SpecificationName:="MyImportSpec", TableName:="tblImport", FileName:="D:TextFilesData.txt", HasFieldNames:=False

    Of course, you must substitute the appropriate names.

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Import automation (2000 SR1)

    Hi Matt,
    You need the DoCmd.TransferText method. e.g.
    <pre>DoCmd.TransferText acImportFixed, "Import specification name goes here", "Table name goes here", "Text file name goes here", True
    </pre>

    The True on the end means that your text file contains field names on the first row. Change it to false if this is not the case. I have also assumed that it's a fixed width format - if it's delimited, change the acImportFixed to acImportDelim.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    2 Star Lounger
    Join Date
    May 2002
    Location
    Bristol, Avon, England
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import automation (2000 SR1)

    Guys, Thanks. It works perfectly

Posting Permissions

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