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

Text file import to Access Table

Status
Not open for further replies.

tnayfeh

Programmer
Apr 21, 2004
39
CA
Hi there,
I'm very new to VBA. Here's sample from a text file that I'd like to import into an Access table I've created. I'm using a form with a text box with the path (txtFileName) and an import button (cmdImport).

-----------------------
DataSource 429 "Map_company" Separator "," SourceType FlatFile_ColNames
CharacterSet Ansi DecimalSep " " Thousandsep " " Columns True Timing PopYesCreateDefault
Source "d:\excel\mcomp.csv" EnableMultiProcess True SetCurrent False
ServerSource False Speed False Presummarized False
---------------------------

I need a function that will go through the file line by line. Once it reaches a line that begins with "Source" it will copy the path "d:\excel\mcomp.csv" to the table (tbl_Values) with only 1 field (Source).

Thanks in advance.
TN
 
You only need to get that one item out of the file?

Look at these functions in the help file for starters:

FreeFile()
Open #
LineInput
Left()
InStr()
Mid()

Basically, you'll open the file, process each line until you find one that has a left set of 6 characters that is "Source", and then you will use the Mid() and InStr() functions to get the piece of information that you want out of the string.

If you need help with this, post back.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top