Hi
I'm trying to import the contents of a text file which is basically letters
in to a table to add more data to them. The original file comes from the
mainframe.
I'm tring to copy the recordset code someone else used to do a similar job a
few years ago. As I'm fairly new to vb. There are 49 lines of text in each
letter, there can be any number of letters in the file and when I run the
code I get 'Runtime error 62 input past end of file' even though the
linecounter has only got to line37.
Can someone give me some ideas where I''m wrong please?
Thanks
Wendy
Option Compare Database
Option Explicit
Public Linecounter As Integer
Public fn As String
Public Dataline(49)
Public dbs As DAO.Database
Public rstltrs As DAO.Recordset
Sub Ltrcode_Filter( )
fn = "C:\import\sc.t xt"
While fn <""
Open fn For Input As #1
While Not EOF(1)
For Linecounter = 1 To 49
Line Input #1, Dataline(Lineco unter)
Next Linecounter
' SETUP DATASET
Dim dbs As DAO.Database
Dim rstltrs As DAO.Recordset
Set dbs = CurrentDb
Set rstltrs = CurrentDb.OpenR ecordset("TBLLt rs", dbOpenDynaset)
'UPDATE RECORD (Parse Record)
With rstltrs
.AddNew
!CaseNo = Val(Mid(Datalin e(14), 47, 8))
!Ref = Mid(Dataline(15 ), 49, 15)
!Name = Trim(Dataline(1 0))
.Update
End With
Wend
Close #1
Wend
End Sub
I'm trying to import the contents of a text file which is basically letters
in to a table to add more data to them. The original file comes from the
mainframe.
I'm tring to copy the recordset code someone else used to do a similar job a
few years ago. As I'm fairly new to vb. There are 49 lines of text in each
letter, there can be any number of letters in the file and when I run the
code I get 'Runtime error 62 input past end of file' even though the
linecounter has only got to line37.
Can someone give me some ideas where I''m wrong please?
Thanks
Wendy
Option Compare Database
Option Explicit
Public Linecounter As Integer
Public fn As String
Public Dataline(49)
Public dbs As DAO.Database
Public rstltrs As DAO.Recordset
Sub Ltrcode_Filter( )
fn = "C:\import\sc.t xt"
While fn <""
Open fn For Input As #1
While Not EOF(1)
For Linecounter = 1 To 49
Line Input #1, Dataline(Lineco unter)
Next Linecounter
' SETUP DATASET
Dim dbs As DAO.Database
Dim rstltrs As DAO.Recordset
Set dbs = CurrentDb
Set rstltrs = CurrentDb.OpenR ecordset("TBLLt rs", dbOpenDynaset)
'UPDATE RECORD (Parse Record)
With rstltrs
.AddNew
!CaseNo = Val(Mid(Datalin e(14), 47, 8))
!Ref = Mid(Dataline(15 ), 49, 15)
!Name = Trim(Dataline(1 0))
.Update
End With
Wend
Close #1
Wend
End Sub
Comment