PDA

View Full Version : Using 'Ontime'



mferrisi
04-17-2007, 02:06 PM
I have a program that needs to wait a few seconds for data to upload before it continues, and my code isn't pausing (or running "Get_Stats")
The data is downloaded via development, an I need to pause to make sure it is in before the columns are deleted. Am I missing something? Thank you.


Sub Main()

Call Development

Dim RunWhen As Double
Const cRunIntervalSeconds = 5 ' two minutes
Const cRunWhat = "Get_Stats"
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, schedule:=True

ThisWorkbook.Sheets("Development").Columns("J:BJ").Delete

End Sub

mdmackillop
04-17-2007, 03:07 PM
Have a look here (http://www.vbaexpress.com/forum/showthread.php?p=92300#post92300) for some possible solutions

Bob Phillips
04-17-2007, 03:46 PM
Not sure why you delete after issung the Delete after the Ontime, isn't it that that you wish to wait for? If so



Sub Main()

Call Development

Dim RunWhen As Double
Const cRunIntervalSeconds = 5 ' two minutes
Const cRunWhat = "Get_Stats"
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, schedule:=True
End Sub

Sub Get_Stats()

ThisWorkbook.Sheets("Development").Columns("J:BJ").Delete

End Sub

Paul_Hossler
04-17-2007, 06:36 PM
I'd call the 'Sleep' API, and not mess around with OnTime just to delay a little


Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


'pass the amount of time (in milliseconds)
Sub TakeNap(timelength As Long)
Sleep (timelength)
End Sub



Paul

tstom
04-18-2007, 08:47 PM
The data is downloaded via development

By way of MS Query? If so, you might want to consider using the AfterUpdate event...