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 Mike Lewis 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
0
0
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

 
Looking at your If statements it seems that your logic may be not quite right. I've written what I believe to be correct, but it's difficult for me to be sure. I hope this will be of some help. This is just a sketch, you will have to adapt this to your project.

If Left$(myrec, 8) <> &quot; &quot; Then
'look for an existing record
sakla = Left$(myrec, 8)
tb.Seek &quot;=&quot;, sakla, 2
If tb.NoMatch Then
'there is no existing record
'add a new record
Else
'found an existing record, add to it
'concatenate to ACIKLAMA here
End If
Else
'this is a line from a record that we
'already created
'concatenate to ACIKLAMA here
End If
Loop &quot;The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!&quot;
 
I have a text file, I am having a problem even importing the data into Access. I know I have to open a new file, then import the data ... or retype the whole stupid thing. I've not done this in so long, I can't remember HOW to import. What I have to have done is have the document at show on the page ... only one line of information at a time, not the whole page. I have a deadline of December 28th to get it done.

I know I have the link code right, or I did ... now I need to import to Access, the information in the text file.

Any assistance would be very much appreciated.

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top