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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing CSV into Access 2003

Status
Not open for further replies.

merlynsdad

Programmer
Nov 18, 2010
175
US
I need to import a csv file into a new Access 2003 table using VBA. The file I'm given has 24 fields, but I only need 8 of them, and if I could change their field names that would be nice.

Code:
DoCmd.TransferText acImportDelim, , "tblTestCSV2", "S:\WI\ACS\ACS QA\weektest.csv", True, ""

brings in all 24 fields. Is there a way to only bring in the ones I want, or is it better to bring in the whole file and then delete the fields I don't want?

If the square peg won't fit in the round hole, sand off the corners.
 
Use a specification file.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OK, I looked up "specification file" as I've never heard of it before. I've also never imported csv files before, which may be why. If I import this file manually I can select the fields I need, but I'm trying to do this in VBA, and have no clue how to use a specification file in VBA.

If the square peg won't fit in the round hole, sand off the corners.
 
Save the specifications when you do the import manually and then use it in VBA as the 2nd parameter of the TransferText method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OK, I figured out how to serup the specification file in VBA. Thanks for the assistance.

If the square peg won't fit in the round hole, sand off the corners.
 
Sorry, but I didn't see the posts by PHV and Andrzejek before I figured it out. But I still have a problem. I need to trim 5 spaces from the left side of one field. Is it possible using the import specification box to trim this as I bring it in, or do I need to use LTrim after it's in? Also, how do I bring up the import specification box by itself?

If the square peg won't fit in the round hole, sand off the corners.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top