Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-access > #10581 > unrolled thread

On Error not working

Started by"Phil" <phil@stantonfamily.co.uk>
First post2015-04-07 14:51 +0100
Last post2015-04-10 07:16 +0100
Articles 11 — 4 participants

Back to article view | Back to comp.databases.ms-access


Contents

  On Error not working "Phil" <phil@stantonfamily.co.uk> - 2015-04-07 14:51 +0100
    Re: On Error not working Patrick Finucane <patrickfinucanetx@gmail.com> - 2015-04-07 06:59 -0700
      Re: On Error not working "Phil" <phil@stantonfamily.co.uk> - 2015-04-07 18:23 +0100
      Re: On Error not working "Phil" <phil@stantonfamily.co.uk> - 2015-04-07 18:27 +0100
        Re: On Error not working Larry Linson <larry.linson@verizon.net> - 2015-04-08 22:53 -0500
          Re: On Error not working "Phil" <phil@stantonfamily.co.uk> - 2015-04-09 08:13 +0100
            Re: On Error not working Larry Linson <larry.linson@verizon.net> - 2015-04-09 15:08 -0500
              Re: On Error not working "Phil" <phil@stantonfamily.co.uk> - 2015-04-10 07:11 +0100
                Re: On Error not working Larry Linson <larry.linson@verizon.net> - 2015-04-10 21:54 -0500
            Re: On Error not working "Ron Paii" <None@none.com> - 2015-04-09 15:59 -0500
              Re: On Error not working "Phil" <phil@stantonfamily.co.uk> - 2015-04-10 07:16 +0100

#10581 — On Error not working

From"Phil" <phil@stantonfamily.co.uk>
Date2015-04-07 14:51 +0100
SubjectOn Error not working
Message-ID<mg0ndg$jbd$1@speranza.aioe.org>
Dim Word As String

OpenTempFile:
    ' Open file for output.
    Open TempFile For Output As #1
    
    Print #1, xmlHttp.responseText
    
    Close #1
    
    Open TempFile For Input As #1
        
    Do While Not EOF(1)
NextLine:
        On Error GoTo GetShareValue_Err
        Line Input #1, Word      ' #####################


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

[toc] | [next] | [standalone]


#10586

FromPatrick Finucane <patrickfinucanetx@gmail.com>
Date2015-04-07 06:59 -0700
Message-ID<eb16bec6-4e02-4ee1-83f2-efd337b8d4c2@googlegroups.com>
In reply to#10581
On Tuesday, April 7, 2015 at 9:51:57 AM UTC-4, Phil wrote:
> Dim Word As String
> 
> OpenTempFile:
>     ' Open file for output.
>     Open TempFile For Output As #1
>     
>     Print #1, xmlHttp.responseText
>     
>     Close #1
>     
>     Open TempFile For Input As #1
>         
>     Do While Not EOF(1)
> NextLine:
>         On Error GoTo GetShareValue_Err
>         Line Input #1, Word      ' #####################
> 
> 
> ---
> This email has been checked for viruses by Avast antivirus software.
> http://www.avast.com

What's the issue?

[toc] | [prev] | [next] | [standalone]


#10588

From"Phil" <phil@stantonfamily.co.uk>
Date2015-04-07 18:23 +0100
Message-ID<mg13pr$m24$1@speranza.aioe.org>
In reply to#10586
> What's the issue?
> 

Sorry Patrick, something went went wrong with the post.

The complete posting should have been:
    ' Open file for output.
    Open TempFile For Output As #1
    
    Print #1, xmlHttp.responseText
    
    Close #1
    
    Open TempFile For Input As #1
        
    Do While Not EOF(1)
NextLine:
        On Error GoTo GetShareValue_Err
        Line Input #1, Word      ' #####################


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#10589

From"Phil" <phil@stantonfamily.co.uk>
Date2015-04-07 18:27 +0100
Message-ID<mg1414$mo6$1@speranza.aioe.org>
In reply to#10586
> 
> What's the issue?
> 


Sorry Patrick, something went went wrong with the post.

The complete posting should have been:
    ' Open file for output.
    Open TempFile For Output As #1
    
    Print #1, xmlHttp.responseText
    
    Close #1
    
    Open TempFile For Input As #1
        
    Do While Not EOF(1)
NextLine:
        On Error GoTo GetShareValue_Err
        Line Input #1, Word 


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#10595

FromLarry Linson <larry.linson@verizon.net>
Date2015-04-08 22:53 -0500
Message-ID<6etbia9mqardpf93pmhhhq5o971hl5p0md@4ax.com>
In reply to#10589
On Tue, 7 Apr 2015 18:27:00 +0100, "Phil" <phil@stantonfamily.co.uk>
wrote:

As best I can tell, Phil, you simply repeated the post about which
Patrick asked "what is the issue?"  It was code, with no explanation
of what you expect, what is actually happening, and why you think "On
Error Not Working". That's rather like expecting someone who doesn't
speak your language to understand if you only say it louder.

Just posting code that doesn't work as you think it ought to work is
not sufficient information for anyone to assist you. Sorry.

 Larry

[toc] | [prev] | [next] | [standalone]


#10596

From"Phil" <phil@stantonfamily.co.uk>
Date2015-04-09 08:13 +0100
Message-ID<mg58rq$al9$1@speranza.aioe.org>
In reply to#10595
On 09/04/2015 04:53:45, Larry Linson wrote:
> On Tue, 7 Apr 2015 18:27:00 +0100, "Phil" <phil@stantonfamily.co.uk>
> wrote:
> 
> As best I can tell, Phil, you simply repeated the post about which
> Patrick asked "what is the issue?"  It was code, with no explanation
> of what you expect, what is actually happening, and why you think "On
> Error Not Working". That's rather like expecting someone who doesn't
> speak your language to understand if you only say it louder.
> 
> Just posting code that doesn't work as you think it ought to work is
> not sufficient information for anyone to assist you. Sorry.
> 
> Larry
> 

Patric, Larry, sorry for the confusion. 
I was having rtouble with my news reader and the correct post went wrong.

Try again

What I am doing is reading a web page into a text file 
and scanning the text file for sequences of words which
eventuall allow me to extract a share price.
This works perfectly unless the Web page is experiencing
a problem, and in this case I suspect that the required
sequence does not exist.

Most of the relevent code is here.

Dim Word as String

OpenTempFile:
    ' Open file for output.
    Open TempFile For Output As #1
    
    Print #1, xmlHttp.responseText
    
    Close #1
    
    Open TempFile For Input As #1
        
    Do While Not EOF(1)
NextLine:
        On Error GoTo GetShareValue_Err
        Line Input #1, Word

GetShareValue_Exit:
    Exit Function
    
GetShareValue_Err:
    If Err = 62 Then
FileEndFound EndFound = FileEndFound + 1 ' The temp file may not have any
linefeeds, ' so try for for other codes
        If FileEndFound < 2 Then                            ' 2 attempts
            Err.Clear
            GoTo CheckCode
        Else
MsgBox MsgBox "Failed to find the price - the code may be wrong",
vbInformation             Call Shell(NotepadFile & " " & TempFile)
            GoTo GetShareValue_Exit
        End If
    ElseIf Err = 55 Then                    ' File already open
        Close #1
        GoTo OpenTempFile
    ElseIf Err = -2147352567 Then           ' No current record
        MsgBox "No search string have been set", vbCritical
        GoTo GetShareValue_Exit
    Else
        MsgBox Err & "  " & Err.Description
    End If

The problem is that on the  line Line Input #1, Word,
I get a runtime error 62 - Input past end of file

It fails to run the error routine.

Phil

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#10598

FromLarry Linson <larry.linson@verizon.net>
Date2015-04-09 15:08 -0500
Message-ID<kuldiap2hguce71h813fgcutn23hr2rg59@4ax.com>
In reply to#10596
That's a lot more information. Now I have a few questions... (but I
will note that seems a ccomplicated way to accomplish your purpose):


Q1. I have to ask, are you using Microsoft Access?  If so, what
version?

Q2. Why do you find it necessary to write a value to which you must
already have access in VBA to a sequential file, and then to read it
back?

Q3. In re:  xmlHttp.responseText, do you have xmlHttp
defined/referenced as an object, and does it have a property named
responseText?

Q4.  Have you set a debug stop in your code and checked to see if the
value you are referencing, xmlHttp.responseText, has a value?

Q5. Have you, later, opened the file and determined that it contains a
record and that record has a value?

I'm just guessing, but it appears you may be exiting the do loop
because you encounter an EOF and, thus, never execute the Line Input
that would trigger the error. I'm not certain, but your finding the
answers to the questions I ask may be helpful.

 Regards,
 Larry


On Thu, 9 Apr 2015 08:13:59 +0100, "Phil" <phil@stantonfamily.co.uk>
wrote:

>On 09/04/2015 04:53:45, Larry Linson wrote:
>> On Tue, 7 Apr 2015 18:27:00 +0100, "Phil" <phil@stantonfamily.co.uk>
>> wrote:
>> 
>> As best I can tell, Phil, you simply repeated the post about which
>> Patrick asked "what is the issue?"  It was code, with no explanation
>> of what you expect, what is actually happening, and why you think "On
>> Error Not Working". That's rather like expecting someone who doesn't
>> speak your language to understand if you only say it louder.
>> 
>> Just posting code that doesn't work as you think it ought to work is
>> not sufficient information for anyone to assist you. Sorry.
>> 
>> Larry
>> 
>
>Patric, Larry, sorry for the confusion. 
>I was having rtouble with my news reader and the correct post went wrong.
>
>Try again
>
>What I am doing is reading a web page into a text file 
>and scanning the text file for sequences of words which
>eventuall allow me to extract a share price.
>This works perfectly unless the Web page is experiencing
>a problem, and in this case I suspect that the required
>sequence does not exist.
>
>Most of the relevent code is here.
>
>Dim Word as String
>
>OpenTempFile:
>    ' Open file for output.
>    Open TempFile For Output As #1
>    
>    Print #1, xmlHttp.responseText
>    
>    Close #1
>    
>    Open TempFile For Input As #1
>        
>    Do While Not EOF(1)
>NextLine:
>        On Error GoTo GetShareValue_Err
>        Line Input #1, Word
>
>GetShareValue_Exit:
>    Exit Function
>    
>GetShareValue_Err:
>    If Err = 62 Then
>FileEndFound EndFound = FileEndFound + 1 ' The temp file may not have any
>linefeeds, ' so try for for other codes
>        If FileEndFound < 2 Then                            ' 2 attempts
>            Err.Clear
>            GoTo CheckCode
>        Else
>MsgBox MsgBox "Failed to find the price - the code may be wrong",
>vbInformation             Call Shell(NotepadFile & " " & TempFile)
>            GoTo GetShareValue_Exit
>        End If
>    ElseIf Err = 55 Then                    ' File already open
>        Close #1
>        GoTo OpenTempFile
>    ElseIf Err = -2147352567 Then           ' No current record
>        MsgBox "No search string have been set", vbCritical
>        GoTo GetShareValue_Exit
>    Else
>        MsgBox Err & "  " & Err.Description
>    End If
>
>The problem is that on the  line Line Input #1, Word,
>I get a runtime error 62 - Input past end of file
>
>It fails to run the error routine.
>
>Phil
>
>---
>This email has been checked for viruses by Avast antivirus software.
>http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#10602

From"Phil" <phil@stantonfamily.co.uk>
Date2015-04-10 07:11 +0100
Message-ID<mg7pij$n78$1@speranza.aioe.org>
In reply to#10598
On 09/04/2015 21:08:29, Larry Linson wrote:
> 
> That's a lot more information. Now I have a few questions... (but I
> will note that seems a ccomplicated way to accomplish your purpose):
> 
> 
> Q1. I have to ask, are you using Microsoft Access?  If so, what
> version?
> 
> Q2. Why do you find it necessary to write a value to which you must
> already have access in VBA to a sequential file, and then to read it
> back?
> 
> Q3. In re:  xmlHttp.responseText, do you have xmlHttp
> defined/referenced as an object, and does it have a property named
> responseText?
> 
> Q4.  Have you set a debug stop in your code and checked to see if the
> value you are referencing, xmlHttp.responseText, has a value?
> 
> Q5. Have you, later, opened the file and determined that it contains a
> record and that record has a value?
> 
> I'm just guessing, but it appears you may be exiting the do loop
> because you encounter an EOF and, thus, never execute the Line Input
> that would trigger the error. I'm not certain, but your finding the
> answers to the questions I ask may be helpful.
> 
> Regards,
> Larry
> 
> 
> On Thu, 9 Apr 2015 08:13:59 +0100, "Phil" <phil@stantonfamily.co.uk>
> wrote:
> 
>>On 09/04/2015 04:53:45, Larry Linson wrote:
>>> On Tue, 7 Apr 2015 18:27:00 +0100, "Phil" <phil@stantonfamily.co.uk>
>>> wrote:
>>>
>>> As best I can tell, Phil, you simply repeated the post about which
>>> Patrick asked "what is the issue?"  It was code, with no explanation
>>> of what you expect, what is actually happening, and why you think "On
>>> Error Not Working". That's rather like expecting someone who doesn't
>>> speak your language to understand if you only say it louder.
>>>
>>> Just posting code that doesn't work as you think it ought to work is
>>> not sufficient information for anyone to assist you. Sorry.
>>>
>>> Larry
>>>
>>
>>Patric, Larry, sorry for the confusion.
>>I was having rtouble with my news reader and the correct post went wrong.
>>
>>Try again
>>
>>What I am doing is reading a web page into a text file
>>and scanning the text file for sequences of words which
>>eventuall allow me to extract a share price.
>>This works perfectly unless the Web page is experiencing
>>a problem, and in this case I suspect that the required
>>sequence does not exist.
>>
>>Most of the relevent code is here.
>>
>>Dim Word as String
>>
>>OpenTempFile:
>>    ' Open file for output.
>>    Open TempFile For Output As #1
>>
>>    Print #1, xmlHttp.responseText
>>
>>    Close #1
>>
>>    Open TempFile For Input As #1
>>
>>    Do While Not EOF(1)
>>NextLine:
>>        On Error GoTo GetShareValue_Err
>>        Line Input #1, Word
>>
>>GetShareValue_Exit:
>>    Exit Function
>>
>>GetShareValue_Err:
>>    If Err = 62 Then
>>FileEndFound EndFound = FileEndFound + 1 ' The temp file may not have any
>>linefeeds, ' so try for for other codes
>>        If FileEndFound < 2 Then                            ' 2 attempts
>>            Err.Clear
>>            GoTo CheckCode
>>        Else
>>MsgBox MsgBox "Failed to find the price - the code may be wrong",
>>vbInformation             Call Shell(NotepadFile & " " & TempFile)
>>            GoTo GetShareValue_Exit
>>        End If
>>    ElseIf Err = 55 Then                    ' File already open
>>        Close #1
>>        GoTo OpenTempFile
>>    ElseIf Err = -2147352567 Then           ' No current record
>>        MsgBox "No search string have been set", vbCritical
>>        GoTo GetShareValue_Exit
>>    Else
>>        MsgBox Err & "  " & Err.Description
>>    End If
>>
>>The problem is that on the  line Line Input #1, Word,
>>I get a runtime error 62 - Input past end of file
>>
>>It fails to run the error routine.
>>
>>Phil
>>
Thanks for coming back, Larry
Q1 Access 2010 with Windows 7

Q2 Other bits
Dim html As Object, xmlHttp As Object
Dim TempFile As String      ‘Full path to a temporary Txt File
Dim URL As String   ‘ This is URL of the Website defined in a table

   Set xmlHttp = CreateObject("MSXML2.XMLHTTP")

    URL = TempWEBPage

    xmlHttp.Open "GET", URL, False
    xmlHttp.setRequestHeader "Content-Type", "text/xml"
    xmlHttp.Send

    Set html = CreateObject("htmlfile")
    html.Body.innerHTML = xmlHttp.responseText
    
OpenTempFile:
    ' Open file for output.
    Open TempFile For Output As #1
    
    Print #1, xmlHttp.responseText
    
    Close #1           
    Open TempFile For Input As #1
        
    Do While Not EOF(1)
NextLine:
        On Error GoTo GetShareValue_Err
        Line Input #1, Word

Q3 Yes to all

Q4 & Q5 Yes and I can look at the TempFile and see that it has data in it. 
Normally it will have certain strings that I search for (defined in a table)
and after searching for perhaps 2 or three strings within the TempFile, I
find the price I am looking for. This always works perfectly. 
Where it is failing is if the Website reports an error, so the strings I am
searching for are not there.

So for example 
URL = https://uk.finance.yahoo.com/q?s=BP.L
Search strings are id="yfs_l84_BP.L">
                                </span></span>
The relevant line in the TempFile is 
id="yfs_l84_BP.l">463.70</span></span>
and 463.7 is the price I am looking for.
I have defined in the Access table that id="yfs_l84_BP.L"> immediately
precedes the price

Anyway I think Ron Paii is correct that I haven’t got a resume in my Error
Routine, so I will try that and see if next time the Website goes down
whether I get the correct errors.

Phil



---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#10607

FromLarry Linson <larry.linson@verizon.net>
Date2015-04-10 21:54 -0500
Message-ID<tp2hia9dk851u96la875b0hj3qh162l77d@4ax.com>
In reply to#10602
On Fri, 10 Apr 2015 07:11:26 +0100, "Phil" <phil@stantonfamily.co.uk>
wrote:

>On 09/04/2015 21:08:29, Larry Linson wrote:
>> 
>> That's a lot more information. Now I have a few questions... (but I
>> will note that seems a ccomplicated way to accomplish your purpose):
>> 
>> 
>> Q1. I have to ask, are you using Microsoft Access?  If so, what
>> version?
>> 
>> Q2. Why do you find it necessary to write a value to which you must
>> already have access in VBA to a sequential file, and then to read it
>> back?
>> 
>> Q3. In re:  xmlHttp.responseText, do you have xmlHttp
>> defined/referenced as an object, and does it have a property named
>> responseText?
>> 
>> Q4.  Have you set a debug stop in your code and checked to see if the
>> value you are referencing, xmlHttp.responseText, has a value?
>> 
>> Q5. Have you, later, opened the file and determined that it contains a
>> record and that record has a value?
>> 
>> I'm just guessing, but it appears you may be exiting the do loop
>> because you encounter an EOF and, thus, never execute the Line Input
>> that would trigger the error. I'm not certain, but your finding the
>> answers to the questions I ask may be helpful.
>> 
>> Regards,
>> Larry
>> 
>> 
>> On Thu, 9 Apr 2015 08:13:59 +0100, "Phil" <phil@stantonfamily.co.uk>
>> wrote:
>> 
>>>On 09/04/2015 04:53:45, Larry Linson wrote:
>>>> On Tue, 7 Apr 2015 18:27:00 +0100, "Phil" <phil@stantonfamily.co.uk>
>>>> wrote:
>>>>
>>>> As best I can tell, Phil, you simply repeated the post about which
>>>> Patrick asked "what is the issue?"  It was code, with no explanation
>>>> of what you expect, what is actually happening, and why you think "On
>>>> Error Not Working". That's rather like expecting someone who doesn't
>>>> speak your language to understand if you only say it louder.
>>>>
>>>> Just posting code that doesn't work as you think it ought to work is
>>>> not sufficient information for anyone to assist you. Sorry.
>>>>
>>>> Larry
>>>>
>>>
>>>Patric, Larry, sorry for the confusion.
>>>I was having rtouble with my news reader and the correct post went wrong.
>>>
>>>Try again
>>>
>>>What I am doing is reading a web page into a text file
>>>and scanning the text file for sequences of words which
>>>eventuall allow me to extract a share price.
>>>This works perfectly unless the Web page is experiencing
>>>a problem, and in this case I suspect that the required
>>>sequence does not exist.
>>>
>>>Most of the relevent code is here.
>>>
>>>Dim Word as String
>>>
>>>OpenTempFile:
>>>    ' Open file for output.
>>>    Open TempFile For Output As #1
>>>
>>>    Print #1, xmlHttp.responseText
>>>
>>>    Close #1
>>>
>>>    Open TempFile For Input As #1
>>>
>>>    Do While Not EOF(1)
>>>NextLine:
>>>        On Error GoTo GetShareValue_Err
>>>        Line Input #1, Word
>>>
>>>GetShareValue_Exit:
>>>    Exit Function
>>>
>>>GetShareValue_Err:
>>>    If Err = 62 Then
>>>FileEndFound EndFound = FileEndFound + 1 ' The temp file may not have any
>>>linefeeds, ' so try for for other codes
>>>        If FileEndFound < 2 Then                            ' 2 attempts
>>>            Err.Clear
>>>            GoTo CheckCode
>>>        Else
>>>MsgBox MsgBox "Failed to find the price - the code may be wrong",
>>>vbInformation             Call Shell(NotepadFile & " " & TempFile)
>>>            GoTo GetShareValue_Exit
>>>        End If
>>>    ElseIf Err = 55 Then                    ' File already open
>>>        Close #1
>>>        GoTo OpenTempFile
>>>    ElseIf Err = -2147352567 Then           ' No current record
>>>        MsgBox "No search string have been set", vbCritical
>>>        GoTo GetShareValue_Exit
>>>    Else
>>>        MsgBox Err & "  " & Err.Description
>>>    End If
>>>
>>>The problem is that on the  line Line Input #1, Word,
>>>I get a runtime error 62 - Input past end of file
>>>
>>>It fails to run the error routine.
>>>
>>>Phil
>>>
>Thanks for coming back, Larry
>Q1 Access 2010 with Windows 7
>
>Q2 Other bits
>Dim html As Object, xmlHttp As Object
>Dim TempFile As String      ‘Full path to a temporary Txt File
>Dim URL As String   ‘ This is URL of the Website defined in a table
>
>   Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
>
>    URL = TempWEBPage
>
>    xmlHttp.Open "GET", URL, False
>    xmlHttp.setRequestHeader "Content-Type", "text/xml"
>    xmlHttp.Send
>
>    Set html = CreateObject("htmlfile")
>    html.Body.innerHTML = xmlHttp.responseText
>    
>OpenTempFile:
>    ' Open file for output.
>    Open TempFile For Output As #1
>    
>    Print #1, xmlHttp.responseText
>    
>    Close #1           
>    Open TempFile For Input As #1
>        
>    Do While Not EOF(1)
>NextLine:
>        On Error GoTo GetShareValue_Err
>        Line Input #1, Word
>
>Q3 Yes to all
>
>Q4 & Q5 Yes and I can look at the TempFile and see that it has data in it. 
>Normally it will have certain strings that I search for (defined in a table)
>and after searching for perhaps 2 or three strings within the TempFile, I
>find the price I am looking for. This always works perfectly. 
>Where it is failing is if the Website reports an error, so the strings I am
>searching for are not there.
>
>So for example 
>URL = https://uk.finance.yahoo.com/q?s=BP.L
>Search strings are id="yfs_l84_BP.L">
>                                </span></span>
>The relevant line in the TempFile is 
>id="yfs_l84_BP.l">463.70</span></span>
>and 463.7 is the price I am looking for.
>I have defined in the Access table that id="yfs_l84_BP.L"> immediately
>precedes the price
>
>Anyway I think Ron Paii is correct that I haven’t got a resume in my Error
>Routine, so I will try that and see if next time the Website goes down
>whether I get the correct errors.
>
>Phil

Well, Phil. I have not used the features you are using, and I've just
about exhausted my questions just on use of VBA.  Looks as if Ron is
pursuing that same paths. I wish you good fortune in step by step
making your way to the solution.

 Larry

[toc] | [prev] | [next] | [standalone]


#10599

From"Ron Paii" <None@none.com>
Date2015-04-09 15:59 -0500
Message-ID<mg6p6h$r0k$1@dont-email.me>
In reply to#10596

"Phil" <phil@stantonfamily.co.uk> wrote in message 
news:mg58rq$al9$1@speranza.aioe.org...
> On 09/04/2015 04:53:45, Larry Linson wrote:
>> On Tue, 7 Apr 2015 18:27:00 +0100, "Phil" <phil@stantonfamily.co.uk>
>> wrote:
>>
>> As best I can tell, Phil, you simply repeated the post about which
>> Patrick asked "what is the issue?"  It was code, with no explanation
>> of what you expect, what is actually happening, and why you think "On
>> Error Not Working". That's rather like expecting someone who doesn't
>> speak your language to understand if you only say it louder.
>>
>> Just posting code that doesn't work as you think it ought to work is
>> not sufficient information for anyone to assist you. Sorry.
>>
>> Larry
>>
>
> Patric, Larry, sorry for the confusion.
> I was having rtouble with my news reader and the correct post went wrong.
>
> Try again
>
> What I am doing is reading a web page into a text file
> and scanning the text file for sequences of words which
> eventuall allow me to extract a share price.
> This works perfectly unless the Web page is experiencing
> a problem, and in this case I suspect that the required
> sequence does not exist.
>
> Most of the relevent code is here.
>
> Dim Word as String
>
> OpenTempFile:
>    ' Open file for output.
>    Open TempFile For Output As #1
>
>    Print #1, xmlHttp.responseText
>
>    Close #1
>
>    Open TempFile For Input As #1
>
>    Do While Not EOF(1)
> NextLine:
>        On Error GoTo GetShareValue_Err
>        Line Input #1, Word
>
> GetShareValue_Exit:
>    Exit Function
>
> GetShareValue_Err:
>    If Err = 62 Then
> FileEndFound EndFound = FileEndFound + 1 ' The temp file may not have any
> linefeeds, ' so try for for other codes
>        If FileEndFound < 2 Then                            ' 2 attempts
>            Err.Clear
>            GoTo CheckCode
>        Else
> MsgBox MsgBox "Failed to find the price - the code may be wrong",
> vbInformation             Call Shell(NotepadFile & " " & TempFile)
>            GoTo GetShareValue_Exit
>        End If
>    ElseIf Err = 55 Then                    ' File already open
>        Close #1
>        GoTo OpenTempFile
>    ElseIf Err = -2147352567 Then           ' No current record
>        MsgBox "No search string have been set", vbCritical
>        GoTo GetShareValue_Exit
>    Else
>        MsgBox Err & "  " & Err.Description
>    End If
>
> The problem is that on the  line Line Input #1, Word,
> I get a runtime error 62 - Input past end of file
>
> It fails to run the error routine.
>
> Phil
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> http://www.avast.com
>

You never resume from the error; replace the "Go To" statements with 
"Resume" inside you error code. I would also move the "On Error" statement 
to before you attempt to open the file. Open is much more likely to fail 
then Line Input. 

[toc] | [prev] | [next] | [standalone]


#10603

From"Phil" <phil@stantonfamily.co.uk>
Date2015-04-10 07:16 +0100
Message-ID<mg7psl$nu4$1@speranza.aioe.org>
In reply to#10599
On 09/04/2015 21:59:54, "Ron Paii" wrote:
> 
> 
> "Phil" <phil@stantonfamily.co.uk> wrote in message
> news:mg58rq$al9$1@speranza.aioe.org...
>> On 09/04/2015 04:53:45, Larry Linson wrote:
>>> On Tue, 7 Apr 2015 18:27:00 +0100, "Phil" <phil@stantonfamily.co.uk>
>>> wrote:
>>>
>>> As best I can tell, Phil, you simply repeated the post about which
>>> Patrick asked "what is the issue?"  It was code, with no explanation
>>> of what you expect, what is actually happening, and why you think "On
>>> Error Not Working". That's rather like expecting someone who doesn't
>>> speak your language to understand if you only say it louder.
>>>
>>> Just posting code that doesn't work as you think it ought to work is
>>> not sufficient information for anyone to assist you. Sorry.
>>>
>>> Larry
>>>
>>
>> Patric, Larry, sorry for the confusion.
>> I was having rtouble with my news reader and the correct post went wrong.
>>
>> Try again
>>
>> What I am doing is reading a web page into a text file
>> and scanning the text file for sequences of words which
>> eventuall allow me to extract a share price.
>> This works perfectly unless the Web page is experiencing
>> a problem, and in this case I suspect that the required
>> sequence does not exist.
>>
>> Most of the relevent code is here.
>>
>> Dim Word as String
>>
>> OpenTempFile:
>>    ' Open file for output.
>>    Open TempFile For Output As #1
>>
>>    Print #1, xmlHttp.responseText
>>
>>    Close #1
>>
>>    Open TempFile For Input As #1
>>
>>    Do While Not EOF(1)
>> NextLine:
>>        On Error GoTo GetShareValue_Err
>>        Line Input #1, Word
>>
>> GetShareValue_Exit:
>>    Exit Function
>>
>> GetShareValue_Err:
>>    If Err = 62 Then
>> FileEndFound EndFound = FileEndFound + 1 ' The temp file may not have any
>> linefeeds, ' so try for for other codes
>>        If FileEndFound < 2 Then                            ' 2 attempts
>>            Err.Clear
>>            GoTo CheckCode
>>        Else
>> MsgBox MsgBox "Failed to find the price - the code may be wrong",
>> vbInformation             Call Shell(NotepadFile & " " & TempFile)
>>            GoTo GetShareValue_Exit
>>        End If
>>    ElseIf Err = 55 Then                    ' File already open
>>        Close #1
>>        GoTo OpenTempFile
>>    ElseIf Err = -2147352567 Then           ' No current record
>>        MsgBox "No search string have been set", vbCritical
>>        GoTo GetShareValue_Exit
>>    Else
>>        MsgBox Err & "  " & Err.Description
>>    End If
>>
>> The problem is that on the  line Line Input #1, Word,
>> I get a runtime error 62 - Input past end of file
>>
>> It fails to run the error routine.
>>
>> Phil
>>
>> ---
>> This email has been checked for viruses by Avast antivirus software.
>> http://www.avast.com
>>
> 
> You never resume from the error; replace the "Go To" statements with
> "Resume" inside you error code. I would also move the "On Error" statement
> to before you attempt to open the file. Open is much more likely to fail
> then Line Input.
> 
> 

Thanks, Ron. Think you may be right. Can't really check it till the Website
goes down.

Actually I had the On Error statement further up the coding before the Open
TempFile but put it in a second time just for luck.

Phil

Phil

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.databases.ms-access


csiph-web