import a text file

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.
 
A

Albert D. Kallal

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..
 
F

Frank Dulk

The problem is that the file has 12000 pages oh it is difficult to find the
character that the access not to read.
 

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