Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing Text File Problem

Status
Not open for further replies.

pewilson

Technical User
Mar 9, 2001
52
US
I am having difficultly importing a text file into Access through an automated process. I have a form created with a button that will run the process. I'm not understanding what information is needed to provide the DoCmd.TransferText acImportFixed, SpecificationName, TableName, FileName, HasFields protcol. Based upon what I have read, this is what I have intreputted each part as.

acImportFixed = Specifies if I'm importing or exporting. In my case, I'm importing a fixed column file.

SpecificiationName = Specifies if I am using a special file Saved under the Advance options when importing a file. Mine is saved as Attendee/Registrant Import Converter

TableName = Which table I will saving my file as??? <-- Not too sure on this one

FileName = This is the file path of the text file I am importing??? <-- Not too sure on this one either.

Has Fields = I have specified Yes, meaning if my file has row headers.

Currently, this is what my code looks like:
DoCmd.TransferText acImportFixed, &quot;Attendee/Registrant Import Converter&quot;, TableName1, &quot;H:\file_0102.txt&quot;, Yes

If anyone can help really understand this method I would appreciate all your help and support.

Thanks in advance. Paul
paul_wilson74@hotmail.com
 
It's nothing more than that, really. Just creating table TableName from textfile FileName is all, using the specifications in SpecificationName. I had a problem with it once, so I used DoCmd.TransferDatabase. That tends to be more reliable. If TransferText is working for you (doesn't look like anything's wrong), there's really nothing more to it unless I'm misunderstanding the question.
 
You can always design this in a module really easily by making TransferText the option - set it up down in the TransferText's Action Arguments to your specifications. Then setup a line above your TransferText line to Convert Macro to VBA.

The conversion is under:
Action = RunCommand
Command = ConvertMacrostoVisualBasic

This cannot be run from the macro edit mode, you must exit the Macro and double click it from the menu. Now go to your module's area and read the line it outputs. Now you know where everything goes.

Now you can pretty much erase the new macros and modules once you copy/paste out your new TransferText code. Keep this method of finding out how to manipulate new code in mind. It has saved me a lot of trouble.

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Thanks for quick responses. I actually figured out what I was doing wrong for the most part and made the necessary changes. However....... I have run into another little problem. If I manually run the import and specifying the &quot;Specification Name&quot;.... all the fields break out just fine. If I run through my code....well all the fields do not breakout correctly. When I specified acImportDelim, all the data is in one colunm. But when I use acImportFixed, then the data breaks into some of the fields, but not all the fields. So I'm not sure what I may be doing wrong in my code.
This is the code im using right now:
DoCmd.TransferText acImportFixed, &quot;Registration Import New&quot;, &quot;CGS_0102&quot;, &quot;H:\cgs0102.txt&quot;

Any thoughts? Paul
paul_wilson74@hotmail.com
 
DoCmd.TransferText acImportFixed, &quot;Registration Import New&quot;, &quot;CGS_0102&quot;, &quot;H:\cgs0102.txt&quot;, True, &quot;&quot;

Try that.

-Josh
------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top