Importing Text File Into Access Table Format

I have a text file that I am trying to importing into an Access database. The text does follow a structure dut not the best for placing it a table . I have attached an example of what the current text file looks like.

I am trying to get the contents in the text file into a table that has three columns: Student_NM - Student_Major - Student_Class

Is there a way to do this using either VBA or a cmd file that could at least format the data and dump it back into another text file but deliminated?

Any assistance with this would be much appreciated.

Thank you
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It is very simple process bro,

your text file has ordered content and each row separated by 'vbcrlf'  (Asc(13)).
so, you can use vb6 program as following.

1. Load your Text file into Multiline text Box

for i = 1 to len(text1.text)
if j>=3 then
end if
if asc(mid$(text1.text, i,1)) <> 13 then

value1 = value1 & mid$(text1.text, i,1)

if j = 1 then
res.fields('name') = value1

elseif j=2 then
res.fields('major') = value1

elseif j=3 then
res.fields('class') = value1


If you know the Vb6 programming you understand be very easy...

if you need real program please let me know and send original text file with some more records.... i will do and attach.

Run this code in a module:
Private Sub ImportMyFile()
    Const strFile As String = "C:\pathToFile\textfilexample.txt"
    Dim strLine As String
    Dim rs As Recordset
    Dim i As Byte
    Set rs = CurrentDb.OpenRecordset("TableName")
    Open strFile For Input As #1
    Do Until EOF(1)
        i = i + 1
        Line Input #1, strLine
        If i = 1 Then
            rs!Student_NM = strLine
        ElseIf i = 2 Then
            rs!Student_Major = Mid(strLine, 7)
        ElseIf i = 3 Then
            rs!Student_Class = Mid(strLine, 7)
        End If
        If i = 4 Or EOF(1) Then
            i = 0
        End If
    Close #1
    Set rs = Nothing
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
spaced45Author Commented:
Worked perfectly. Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.