How to trigger event by time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lancrye
    New Member
    • Jan 2010
    • 1

    How to trigger event by time

    Hi,

    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)

    Eli
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    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.
    (See: http://msdn.microsoft.com/en-us/library/bb216033.aspx)

    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.

    Nic;o)

    Comment

    • Bartb
      New Member
      • Jul 2006
      • 5

      #3
      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.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
      Dim outfile As String
      Dim objol As New Outlook.Applica tion
      Dim objmail As MailItem
      Set objol = New Outlook.Applica tion
      Set objmail = objol.CreateIte m(olMailItem)
      With objmail

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

      .NoAging = True

      .Display
      .Send

      DoCmd.Close
      End With

      End If

      Comment

      Working...