Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Internet Query control Refresh Rate

Posted on 2011-05-03
Medium Priority
Last Modified: 2012-05-11
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?
Question by:sharkyboy
  • 2
LVL 42

Accepted Solution

dlmille earned 2000 total points
ID: 35517608
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...

LVL 42

Expert Comment

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



Author Closing Comment

ID: 35517740
Yeah :) !!!

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question