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

Importing a text ffile

Status
Not open for further replies.

zishan619

Programmer
May 28, 2003
284
0
0
MX
Hi:
I have a text file that looks something like this:
0195393417 Jan 31 2004 12:24:03PM Z
0195393808 Jan 31 2004 12:34:11PM Z
I need to import this text file into a table using either fso or csv. I do not know how to start this project. Please Help
Thanks
 
If the fields are tab separated then you can simply choose the file and import option within Access.

Based on the layout of the data you would then need to go into the design of the table to set up your field names.


Hope this helps you,


Steve
 
Yes I can do that But I need to write it in code instead of doing a import routine from access. But Thanks
 
' Me.txtInputFileName = Ctrl on Form representing File\Loc
' Me.txtNoOfFields = Ctrl on Form representing # of fields
' rst, Recordset variable ought to match the Input file

Dim rst as Recordset
Dim i as Integer
Dim tTextFile as String
Dim tArray()

Set rst = CurrentDb().OpenRecordset("tbl_SomeTable")

Close #1 ' just in-case it was opened
Open Me.txtInputFileName For Input As #1

ReDim tArray(Me.txtNoOfFields)

Do While Not EOF(1)
Line Input #1, tTextFile

tArray = Split(tTextFile,Chr$(9)) ' if a Tab-delimiter

rst.AddNew
For i = 0 To Me.txtNoOfFields - 1
rst(i) = tArray(i)
Next
rst.Update
Loop

' Housekeeping
Set rst = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top