import a text file

  • Thread starter Thread starter Frank Dulk
  • Start date Start date
F

Frank Dulk

I am I try to import a text file, but that text file has some special
characters that the access doesn't get to matter.

Oh he not to import all the files.

How to solve that problem.
 
Hum, often you can import into Excel...clean it up...and then the data can
be moved to ms-access.

If the text data is too messy, then you can resort to writing your own
import rouintes..but that can be a good deal of work.

The basic code to read a text file via code is:

Sub ReadTextFile

Dim strFile As String
Dim intF As Integer
Dim strLineBuf As String
Dim lngLines As Long
Dim lngBlank As Long

strFile = "c:\my data\MyData.txt"

intF = FreeFile()
Open strFile For Input As #intF

Do While EOF(intF) = False
Line Input #intF, strLineBuf
If Trim(strLineBuf) = "" Then
lngBlank = lngBlank + 1
Else
lngLines = lngLines + 1
End If
Loop
Close intF

End If

MsgBox "Number non blank lines = " & lngLines & vbCrLf & _
"Blank lines = " & lngBlank & vbCrLf & _
"Total = " & lngBlank + lngLines

End Function


The above thus gives you the idea. You could add a few more lines to parse
the data..and write out each line to a table..
 
The problem is that the file has 12000 pages oh it is difficult to find the
character that the access not to read.
 
Back
Top