Messages

Rich1968

Registered User.
Local time
Today, 03:11
Joined
Jan 24, 2003
Messages
57
Hey All!

I have a form called messages. Staff take messages when im out and record them on the DB.

What I would like to do is the following:

Set the on timmer event to run a query called qryMessages every 5 min. If there are any messages the buttom for the form "Messages" on my switchbord blinks.

I have not been very successful doing this using VB code.

Any help would be apprciated.

Rich1968
 
Something like the following will do it, you may need to add some criteria to the DCount depending on whether you delete your messages or flag them as read.


Code:
Private Sub Form_Timer()
    Static lastRun
    Static BlinkTrigger As Boolean
    
    'Debug.Print lastRun, Timer

    'check for messages every 300 seconds
    If Timer - lastRun >= 300 Then
        'query message table
        If DCount("[msgID]", "tblMessages") > 0 Then
            BlinkTrigger = True
        Else
            BlinkTrigger = False
        End If
         lastRun = Timer
    End If
   
    'check if blinking required
     If BlinkTrigger Then
         With Me.btnMsg
            .ForeColor = (IIf(.ForeColor = vbRed, vbBlue, vbRed))
        End With
     Else
            Me.btnMsg.ForeColor = vbBlue
    End If
   
End Sub
 
'check for messages every 300 seconds
If Timer - lastRun >= 300 Then
Actually, the timer is in MILLIseconds so 300 is only 300 milliseconds. One second is 1000 so 300 seconds would be 300000.
 
Actually, the timer is in MILLIseconds so 300 is only 300 milliseconds. One second is 1000 so 300 seconds would be 300000.


You must be thinking of TimerInterval that's milliseconds but the Timer function is seconds:

Timer Function

Returns a Single representing the number of seconds elapsed since midnight.
 

Users who are viewing this thread

Back
Top Bottom