Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2011

    Unanswered: Conditionally Use TransferText


    I have a .txt file which I have successfully imported to my table using the following:

    DoCmd.TransferText acImportDelim, "", "tbl2", "C:\Documents and Settings\ncor\242.txt", True, ""

    The text file has 9 pieces of information each separated by a comma. I have three questions about this:

    1) Is there a way to conditionally import those lines of text? For example, if the second piece of information = 123 , then it gets imported else it does not? I know I'm looking at an if, else clause, but I'm not sure how to get it to go through

    2) This text file will be added to on a daily basis, but I only want to perform the import once a week and I only need the new data to be added. Is there a way to do this? My initial thought is to save the last line number it goes through as a variable and then somehow have it start up at the following line the next time it goes through... but I have no idea how to do this

    3) I will be importing various .txt files into the same table, but I want to be able to differentiate where the data came from. One file will be 242.txt, and another 144.txt ... is there a way to add either "242" or "144" to an additional field when the import is happening according to which file it is coming from?

    I have tried looking online to answers to both of these but have had no luck so far. Someone please help! I'm stuck and have no idea where else to look for possible solutions.

    Thanks in advance!

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 15
    You can do everything you describe, but not while using the DoCmd.TransferText method. You need to write your own set of functions.

    Have a look at this thread: The problem is slightly different but it will give you some ideas on the topic.
    Have a nice day!

Posting Permissions

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