Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-access > #10602
| From | "Phil" <phil@stantonfamily.co.uk> |
|---|---|
| Newsgroups | comp.databases.ms-access |
| Subject | Re: On Error not working |
| Date | 2015-04-10 07:11 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <mg7pij$n78$1@speranza.aioe.org> (permalink) |
| References | (1 earlier) <eb16bec6-4e02-4ee1-83f2-efd337b8d4c2@googlegroups.com> <mg1414$mo6$1@speranza.aioe.org> <6etbia9mqardpf93pmhhhq5o971hl5p0md@4ax.com> <mg58rq$al9$1@speranza.aioe.org> <kuldiap2hguce71h813fgcutn23hr2rg59@4ax.com> |
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
Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web