Help!! importing a text file into access with vba

M

matthewwhaley

I need to import (append) a daily text file into a table. The txt
file is tab delemited and I can't seem to get a schema file to import
starting at row 5.

**Issue #1**


The needed data doesn't start until line 5 in the txt file (line 5-8
needed)


Ex (parenthesis are line number for ref, not in file):
(1) Date: 20070601
(2) Total calculaions ###
(3) Failed calculations ###
(4) Successful Calculations ###
(5) BusID (data is text)
(6) BusName (data is text)
(7) Level assigned (data is text)
(8) Result (data is numeric)


**Issue #2**


The needed data in rows 5-8 is tab delimited and the row label should
be the column header (field) in the database table


Ex (parenthesis are line number for ref, not in file):
(5) "BusID" {tab} "D1 {tab} "D2" ...etc
(6) "BusName" {tab} "AA" {tab} "BB" ... etc
(7) 'Level assigned" {tab} "L1" {tab} "L2" ... etc
(8) "Result" {tab} "123" {tab} "-213" ... etc


So essentially I need to import the txt file starting at row 5 and do
some sort of crosstab import into a table
with a desired result of


BusID BusName Level Assg Result
D1 AA L1 123
D2 BB L2 -213


I think a line input # may work, but I haven't been lucky enough to
get it work.


The following puts all data in one filed with different record for
each line


Dim ImpSpec As String
Dim ImpTbl As String
Dim ImpFile As String


ImpSpec = "Standard Output"
ImpTbl = "SpecificRisk"
ImpFile = "L:\GlobalRiskSupport\MktRiskRegCapital
\EC20070601\outputresults_10d_20070601.txt"


DoCmd.TransferText acLinkDelim, , ImpTbl, ImpFile, True


MsgBox "Records from 'IMPORTED FILE' have been successfully added
to the database."


End Sub


Any help would be appreciated greatly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top