VBA中的计时器循环(访问) [英] Timer looping in vba (Access)

查看:209
本文介绍了VBA中的计时器循环(访问)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置一个计时器,使其在VBA中每3分钟运行一次,以遍历我的Access数据库表并验证数据.我被困在启动计时器的时刻.我写了这个迷你脚本来测试计时器:

I'm trying to configure a timer to run every 3 minutes in VBA, to loop through my Access database table and validate data. I'm stuck at the point of starting the timer. I wrote this mini script to test the timer:

Function JobNameValidate()
MsgBox ("Hello")
'callAgain.OnTimer
End Function

Function callAgain()
callAgain.TimerInterval = 300000
Forms("HiddenForm1").OnTimer
JobNameValidate
End Function

它可以很好地循环,但是无论是否插入TimerInterval,它都可以立即循环.我在网上找不到任何有用的文档.

It loops fine, however it loops instantly, regardless of the TimerInterval put in. I couldn't find any helpful documentation about this online.

推荐答案

您可以将表单的OnTimer属性设置为以=开头的字符串,后跟函数名称和一对括号.

You can set your form's OnTimer property to a string which starts with = followed by your function name and a pair of parentheses.

TimerInterval的单位是毫秒.所以3分钟是180000(3 * 60 * 1000).

The units for TimerInterval are milliseconds. So 3 minutes is 180000 (3 * 60 * 1000).

Function callAgain()
    Forms("HiddenForm1").OnTimer = "=JobNameValidate()"
    Forms("HiddenForm1").TimerInterval = 180000
End Function

我不确定您为什么要使用VBA进行此操作.您可以在表单的属性表中设置这两个属性.但是如果需要,您可以使用VBA来做到这一点.

I'm not sure why you want to do this with VBA. You could set both those properties in the form's property sheet. But you can do it with VBA if needed.

这篇关于VBA中的计时器循环(访问)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆