By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

How to trigger event by time

P: 1

I placed on a userform a label that is showing the current system time - lblClock.
In addition I placed few text boxes with different times.
My problem is that I want to trigger an event any time that the time in one of the text boxes is equal to the time in lblClock as long as the application is opened.

Thanks in advance for your help (access 2007)

Jan 30 '10 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 3,072
You can use the timer interval property of the form. A non zero value (1 equals 1/1000 th of a second) is used to trigger the OnTimer event, allowing you to execute code (testing the text fields) every x seconds.

A warning is however in place. I've experienced that a Timer event can cause the execution of other VBA code to be interrupted and giving strange errors. So I never use the timer event as I only want a "solid" application.

Jan 31 '10 #2

P: 5
try using the following code
Private Sub Form_Timer()
Dim dtrunreport As Date
Dim dtCurTime As Date

dtrunreport = Format(#9:37:00 AM#, "hh:mm")
dtCurTime = Format(Time(), "hh:mm")

If DatePart("w", Date) = 6 Then

If dtCurTime = dtrunreport Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim outfile As String
Dim objol As New Outlook.Application
Dim objmail As MailItem
Set objol = New Outlook.Application
Set objmail = objol.CreateItem(olMailItem)
With objmail

.To = ""
.CC = ""
.Subject = "Check Voicemails"
.Body = ""

.NoAging = True


End With

End If
Feb 3 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.