If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Conditionally Use TransferText

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-12, 09:44
nic311 nic311 is offline
Registered User
 
Join Date: Nov 2011
Posts: 53
Conditionally Use TransferText

Hi,

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!
Reply With Quote
  #2 (permalink)  
Old 01-16-12, 12:06
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
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: Importing Data Form TXT to Access. The problem is slightly different but it will give you some ideas on the topic.
__________________
Have a nice day!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On