安排VBA表单的更新

时间:2015-09-16 14:57:43

标签: sql vba scheduled-tasks userform

我有一个VBA表单,显示从数据库中获取的图表,列表和字段(通过记录集)。 我试图让表单每10秒更新一次,清除文件,图表和列表并运行SQL进行更新。 以下代码应将更新设置为在10秒内运行,并一遍又一遍地执行,直到用户单击关闭,但它不起作用。 没有错误消息,只是没有更新。

Sub UpdateDashboard()
    clearform
    CreatePendingList
    PopulateCheckTimes
    lasthourchart
    createchart
    ScheduleUpdate
End Sub

Sub ScheduleUpdate()
    timetorun = Now + TimeValue("00:00:10")
    MsgBox timetorun
    Application.OnTime timetorun, "UpdateDashboard"
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    Application.OnTime timetorun, "UpdateDashboard", , False
End Sub

0 个答案:

没有答案