spaced45
asked on
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
-textfilexample.txt
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
-textfilexample.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked perfectly. Thanks
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
j=0
end if
if asc(mid$(text1.text, i,1)) <> 13 then
value1 = value1 & mid$(text1.text, i,1)
else
j=j+1
if j = 1 then
res.fields('name') = value1
elseif j=2 then
j=j+1
res.fields('major') = value1
elseif j=3 then
j=j+1
res.fields('class') = value1
endif
Endif
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.
Thanks