Import text file into access

L

little_rascals

Hi, i have to import a text file into access table.
However, there is a header at the top of the text file, which includes
the file name and date of file generated.
I need to extract the date only and input into one of the fields in the
table.

Can anyone kindly tell me how this can be done?!
Thanks!!! :D

Cheers,
little_rascals
 
C

ChrisO

G’day little_rascals…

It depends on the data format of the text file and your experience wit
recordsets.

Therefore this is just a generic reply for opening a text file and doe
not include any recordset manipulation.


Code
-------------------

Option Explicit
Option Compare Text


Private Sub AppendFromCSV()
Dim lngI As Long
Dim strBuffer As String
Dim intFileNumber As Integer

intFileNumber = FreeFile

Open "C:\xyz.csv" For Input As #intFileNumber

' Trash the first ten lines.
' Change 10 to 1 for just the Header.
For lngI = 1 To 10
Line Input #intFileNumber, strBuffer
Next lngI

Do Until EOF(intFileNumber)
Line Input #intFileNumber, strBuffer
'
' Do
' your
' thing.
'
Loop

Close #intFileNumber

End Sub

-------------------
If you wish to save the text file to a Table then please just ask.
I use DAO exclusively and would also need to know what version o
Access you are using.

Also, sample data from the text file and the Table structure would hel
answer your question.

Regards,
Chris
 

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