• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

Internet Query control Refresh Rate

I want to control the refresh rate of my query, the minimum value i can put is 1 minute, i want it in seconds.

Can i create a query using VBA and control his refresh rate?
  • 2
1 Solution
Ok - let's work with OnTime, again :)

Create a subroutine that refreshes your query when you run it, and call that subroutine - "RefreshMyQuery"

Put the below in a public module, and change "refreshTime" variable to however many seconds you want between refreshes...
Public runWhen As Double

Sub refreshQuery()
Dim refreshTime As Double

    Call RefreshMyQuery
    refreshTime = 15
    runWhen = Now() + refreshTime / 86400
    Application.OnTime earliesttime:=runWhen, procedure:="RefreshQuery", schedule:=True

End Sub
Sub StopTimer()
    On Error Resume Next
    Application.OnTime earliesttime:=runWhen, procedure:="RefreshQuery", schedule:=False
End Sub

Open in new window

Also, put a call to StopTimer on workbook exit...

See attached with all in place.  Just add the code that refreshes the query... And update the refreshTime variable for # seconds between refreshes...


sharkyboyAuthor Commented:
Yeah :) !!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now