Web query - when does error occur so I can trap it?

M

Matt Lawson

I am utilizing web queries and other code to copy data all day.

The problem I am having is that I want this program to continually run
without much user intervention, but when there is a problem obtaining data
(website is down, etc out of the codes control), an message displays. The
user can hit okay , and the macro will resume, but I'd like to find a way
around this.

As per Dick Kusleika's blog

See http://www.dicks-blog.com/archives/2004/06/21/classes-other-events/

I was able to use the afterrefresh property to copy values only after the
webquery data was obtained. I figured perhaps adding an On Error Resume
Next in the refresh property ie:

Private Sub gcQueryTable_AfterRefresh(ByVal Success As Boolean)
On Error Resume Next
MsgBox ("After refresh property")
CopyIMODataToMainTracking
Fillin3HourDataForChart
End Sub

HOwever, the "can't find data" error pops up before the messagebox, so I
don't believe this will help me trap the error.

Using Application.DisplayAlerts = False doesn't appear to work either, but
I'm unsure where this should be placed.

Is there any other way to prevent these error messages?

The problem I think is that the error occurs "outside" the procedures (ie
that's why error methods and display alerts doesn't work, since they are used
within confines of a procedure.)

Any ideas?

Thanks again,

Matt Lawson
 
R

Rob van Gelder

Perhaps you could check the Success variable.

If Success Then
MsgBox "After refresh property"
...
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top