ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running SQL Querry after every 10 minutes. (https://www.excelbanter.com/excel-programming/377603-running-sql-querry-after-every-10-minutes.html)

harish

Running SQL Querry after every 10 minutes.
 
Hi All

I have one SQL Querry which I run in background using following code in VBA
macro.

With Selection.QueryTable
.Connection = "ODBC;DSN=MTRAC;UID=mtuser;PWD=mtuser;SERVER=MTUSE R;"
.Refresh BackgroundQuery:=False
End With

This works fine when I run the VBA macro. But I want to run this query in
every 10 minutes for continuous monitoring of the data. I have one standalone
PC for this application where this excel workbook is open all the time. I
know I can use windows scheduler to open this workbook and run the query when
workbook opens. But I am just wondering if there is any other way to do this.

Your help would be greatly appreciated.

Kind Regards
Harish


Mike Woodhouse[_2_]

Running SQL Querry after every 10 minutes.
 

Harish wrote:
Hi All

I have one SQL Querry which I run in background using following code in VBA
macro.

With Selection.QueryTable
.Connection = "ODBC;DSN=MTRAC;UID=mtuser;PWD=mtuser;SERVER=MTUSE R;"
.Refresh BackgroundQuery:=False
End With

This works fine when I run the VBA macro. But I want to run this query in
every 10 minutes for continuous monitoring of the data. I have one standalone
PC for this application where this excel workbook is open all the time. I
know I can use windows scheduler to open this workbook and run the query when
workbook opens. But I am just wondering if there is any other way to do this.

Your help would be greatly appreciated.


Take a look at Application.OnTime in VBA...

Mike


harish

Running SQL Querry after every 10 minutes.
 

"Mike Woodhouse" wrote:


Harish wrote:
Hi All

I have one SQL Querry which I run in background using following code in VBA
macro.

With Selection.QueryTable
.Connection = "ODBC;DSN=MTRAC;UID=mtuser;PWD=mtuser;SERVER=MTUSE R;"
.Refresh BackgroundQuery:=False
End With

This works fine when I run the VBA macro. But I want to run this query in
every 10 minutes for continuous monitoring of the data. I have one standalone
PC for this application where this excel workbook is open all the time. I
know I can use windows scheduler to open this workbook and run the query when
workbook opens. But I am just wondering if there is any other way to do this.

Your help would be greatly appreciated.


Take a look at Application.OnTime in VBA...

Mike


Thanks for your reply.I have used this function but it is quite lenghty
code.As for I have to refresh in every 10 minutes.So for 24 hours I need to
write 144 lines of code.
Is there any other way to do this?

Kind Regards
Harish



All times are GMT +1. The time now is 12:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com