473,756 Members | 6,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recordset

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

Aug 11 '06 #1
5 1851
Put a togglepoint in the code and step through it. I would guess that
line 37 has some issues if you open the TXT file as well, have you
checked it to make sure there wasn't a data drop when you exported it
from the mainframe?

Wendy wrote:
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
Aug 11 '06 #2
I'm not sure what you mean by a toggle point. Looking at it on the locals
window all the data is there, line37 is shown blank just 2 sets of double
quotation marks, its not the only line which is blank though. It also looks
ok when I look at the text file through windows explorer. I just want to
ignore the blank lines. I was trying to catch the data I want by using the
line numbers. Is there a better (easier) way to do it?

Thanks

Wendy

"ManningFan " <ma********@gma il.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Put a togglepoint in the code and step through it. I would guess that
line 37 has some issues if you open the TXT file as well, have you
checked it to make sure there wasn't a data drop when you exported it
from the mainframe?

Wendy wrote:
>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

Aug 11 '06 #3
Wendy wrote:
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


Some considerations:

Line Input # will stop reading text at a CrLf pair. Are their actually
49 "lines" (as defined by a terminal CrLf) or is it possible some of the
lines wrap in whatever you are viewing the data with that gives the
impression there are more than there actually are?

Have you verified that the last successful line read is what you expect
to be line 37?

IIRC If there is no CrLf at the end of the file, Line Input will throw
error 62 upon attempting to read the last line in the input file.

You don't actually need (or want, I suspect) to loop your input
explicitly 49 times. Let EOF do its job. Try something like this:

Linecounter = 0
Do While Not EOF(1)
Line Input #1, Dataline(Lineco unter)
Linecounter = Linecounter + 1
Loop

' SETUP DATASET
....

HTH

--
Smartin
Aug 12 '06 #4
Hi Smartin

Thanks, I'm a little confused, if I don't use line input to loop the 49
times how do I pick out the names and case numbers to put them into a table?

Wendy
"Smartin" <sm********@yah oo.comwrote in message
news:VJ******** *************** *******@giganew s.com...
Wendy wrote:
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

Some considerations:

Line Input # will stop reading text at a CrLf pair. Are their actually
49 "lines" (as defined by a terminal CrLf) or is it possible some of the
lines wrap in whatever you are viewing the data with that gives the
impression there are more than there actually are?

Have you verified that the last successful line read is what you expect
to be line 37?

IIRC If there is no CrLf at the end of the file, Line Input will throw
error 62 upon attempting to read the last line in the input file.

You don't actually need (or want, I suspect) to loop your input
explicitly 49 times. Let EOF do its job. Try something like this:

Linecounter = 0
Do While Not EOF(1)
Line Input #1, Dataline(Lineco unter)
Linecounter = Linecounter + 1
Loop

' SETUP DATASET
...

HTH

--
Smartin

Aug 14 '06 #5
Wendy wrote:
Hi Smartin

Thanks, I'm a little confused, if I don't use line input to loop the 49
times how do I pick out the names and case numbers to put them into a table?

Wendy
"Smartin" <sm********@yah oo.comwrote in message
news:VJ******** *************** *******@giganew s.com...
>Wendy wrote:
>>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


Some considerations:

Line Input # will stop reading text at a CrLf pair. Are their actually
49 "lines" (as defined by a terminal CrLf) or is it possible some of the
lines wrap in whatever you are viewing the data with that gives the
impression there are more than there actually are?

Have you verified that the last successful line read is what you expect
to be line 37?

IIRC If there is no CrLf at the end of the file, Line Input will throw
error 62 upon attempting to read the last line in the input file.

You don't actually need (or want, I suspect) to loop your input
explicitly 49 times. Let EOF do its job. Try something like this:

Linecounter = 0
Do While Not EOF(1)
Line Input #1, Dataline(Lineco unter)
Linecounter = Linecounter + 1
Loop

' SETUP DATASET
...

HTH

--
Smartin

In answer to your question, the example I gave still stores the line
input in the Dataline array just as you were. Each time a line is read
the index is incremented. So you can still pick out Dataline(15), etc.
You were doing the indexing using For..Next. What I did wrong in my
example was Initialize Linecounter = 0 -- you probably want Linecounter = 1.

Without seeing the real input file it's hard to know exactly what's
going wrong, but I suspect it is because you are nesting the For..Next
loop (which reads through the file) inside the While Not EOF loop. A
couple things would throw this off:

Input file < 49 lines: The For..Next loop will try to read past EOF
before the loop is finished.

Input file 49 lines: The first pass will read the entire file and
process it. Then, because you have not reached EOF, everything repeats,
including rewriting the array values. Unless the file is /exactly/ a
multiple of 49 lines long, Line Input will choke somewhere in the
For..Next loop because you aren't testing for EOF in there. That is why
I said let EOF do the work for you.

Lastly, I was mistaken about a final CrLf in the file. The following
file will give EOF = TRUE after reading line 03:

Line 01<CrLf>
Line 02<CrLf>
Line 03

HTH (again)
--
Smartin
Aug 14 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1968
by: gary artim | last post by:
Hi All, I have a problem using DBIx::RecordSet. I get correct results but continue to get these messages on stderr. I looked at Compat.pm and it seems to be pointing out a problem with my call to Setup. Could anyone (much thanks) shed some light on my tired eyes? See below... Gary code sample:
4
3092
by: Tom | last post by:
I want to open a recordset object on an .asp page. When I open the recordset I would like to use a stored procedure that expects a parameter to be passed for the stored procedure. I will then use the recordset to loop thru the recordset, update values from the recordset and then update the database by passing parmeters to another stored procedure. I would like to use the recordset object but can it be used to pass a parameter to a stored...
19
9331
by: Adam Short | last post by:
I am trying to write a routine that will connect a .NET server with a classic ASP server. I know the following code doesn't work! The data is being returned as a dataset, however ASP does not recognise datasets and requires a recordset. Can the datatypes be converted? At the Classic ASP end or .NET end? Can SOAP toolkit provide the conversion, can any toolkit provide a conversion? ...
0
2682
by: CFW | last post by:
I thought this was going to be easy but I'm missing something . . . I need to open an ADODB recordset using the recordset source for a list box on my for. When my form opens, the list box ADODB recordset is established and set during On Open. Next I want to populate a recordset from that list box so I can filter it on a single field using the value of a combo box for the filter string. I have a second combo box that i woul like to use...
6
6555
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query works fine, but passing the resulting recordset back to the sub's caller is not working out.
36
4482
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a dataview with a count = 0. Can someone explain why and how I might work around this problem? Here is the code for my function: Public Shared Function GetViewFromRS(ByVal pRS As ADODB.Recordset) _ As DataView
0
11307
ADezii
by: ADezii | last post by:
Most Access Users realize that Recordsets, being virtual representations of a Query, Table, or SQL Statement, exist only in our PC's memory. They, and the data they contain, literally exist at one specific moment in time - then gone the next. Few of us realize, however, that they can be saved to disk and later retrieved to will. The technical jargon for this is called 'Persisting a Recordset' and I'll show you how it can be done. ADO has this...
0
9006
ADezii
by: ADezii | last post by:
When you create an ADO Recordset, you should have some idea as to what functionality the Recordset does/does not provide. Some critical questions may, and should, be: Can I add New Records to the Recordset? Does the Recordset support Bookmarks? Can we use the Find and/or Seek Methods with this Recordset? Does the Recordset support the use of Indexes? Will the Absoluteposition property be able to be used on this Recordset? etc....
6
5174
by: Oko | last post by:
I'm currently developing an MS Access Data Project (.adp) in MS Access 2002. One of the reports within the DB uses data that is Dynamic and cannot be stored on the SQL Server. To resolve this, I have created an ADODB.Recordset in the reports OPEN event, built the necessary records inside of it, and then bound the report to this newly created recordset. Here's the rub:
2
5515
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my results page. - Recordset Paging works if no parameters are used in the recordset sql code (ie. simple sql code): SELECT * FROM db_name WHERE (db_field1 LIKE ‘%text1%’ OR db_field2 LIKE ‘%text2%’)
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.