Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting text file to database

Status
Not open for further replies.

yesilkalem

IS-IT--Management
Aug 4, 2001
26
TR
hello ..
I have a text file that captured from a terminal screen ..

now I have to analize this text file with access. and I have done this. but have a problem of course ..

I have written a module .. but the in the last column it does not work properly.. I need to concatenate or combine raw1, raw2, raw3... etc. but it combines raw 1, raw2, raw4, raw3 ..

this is my module :

Sub textoku()
Dim db As Database
Dim tb As Recordset
Dim tb1 As Recordset
Dim tb2 As Recordset
Dim tb3 As Recordset
Dim myrec As String * 80
Dim acýk As String
Dim cumle, cumle2, cumle3 As String
Dim sakla As String * 8
Dim TARIH As String * 10
Dim sayý As Integer
Dim myf As Form

Dim sourcefile
sourcefile = Forms!frmtext![DOSYA]
Open sourcefile For Input As #1
Set db = CurrentDb()
db.Execute "delete * from capdata"
Set tb = db.OpenRecordset("capdata")
tb.Index = "PrimaryKey"
sayý = 0

Line Input #1, myrec
Line Input #1, myrec
Do While Not EOF(1)

Line Input #1, myrec

If Left$(myrec, 1) = "-" Then GoTo devam
If Left$(myrec, 8) <> &quot; &quot; Then
sayý = 0
sakla = Left$(myrec, 8)
TARIH = Mid$(myrec, 10, 2) & &quot;.&quot; & Mid$(myrec, 13, 2) & &quot;.&quot; & Mid$(myrec, 16, 4)
End If
If Val(Mid$(myrec, 30, 17)) = 0 Then
tb.Seek &quot;=&quot;, sakla, 2
tb.Edit
tb(&quot;ACIKLAMA&quot;) = tb(&quot;ACIKLAMA&quot;) & Mid$(myrec, 55, 26)
acýk = tb(&quot;ACIKLAMA&quot;)
tb.Update
GoTo devam
End If
tb.AddNew
sayý = sayý + 1
tb(&quot;SIRA&quot;) = sayý
tb(&quot;FISNO&quot;) = sakla
tb(&quot;TARIH&quot;) = TARIH
tb(&quot;HESAP&quot;) = Mid$(myrec, 21, 8)
tb(&quot;b/A&quot;) = Mid$(myrec, 29, 1)
tb(&quot;MEBLAG&quot;) = Int(Mid$(myrec, 30, 17))
tb(&quot;DOVIZ&quot;) = Mid$(myrec, 50, 3)
acýk = &quot;&quot;
acýk = Trim(Mid$(myrec, 55, 26))
tb(&quot;ACIKLAMA&quot;) = acýk
tb.Update
devam:
Loop
kapat:
tb.Close
MsgBox (&quot;Text Datasý Aktarýldý&quot;)
db.Close

End Sub




this is my text file.. please copy it to a text file

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top