Home  |  About  |   Search   

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

RunCommand Constants

Terms of Use


 

Forms: Make a label flash

Author(s)
Dev Ashish

(Q)    How do I make a label flash?

(A)    You have to use the form's Timer event for this.

    For example,  let's say you have a label called "lblSomeLabel" on a form.  Also on the same form you have an embedded subform, the relationship being 1:M.

    Now let's say you want to alert the user by flashing the caption if more than 3 records exist on the subform for each record on the parent form. 

    So, place the following code behind the Timer event.

'************* Code Start *************
Private Sub Form_Timer()
    With Me.lblSomeLabel
        .ForeColor = (IIf(.ForeColor = vbRed, vbBlack, vbRed))
    End With
End Sub
'************* Code End *************

    Now all you need is some code in the main form that triggers the Timer.  Place this code behind the main form's OnCurrent event.

'************* Code Start *************
Private Sub Form_Current()
    If Me![SomeSubForm].Form.RecordsetClone.RecordCount > 3 Then
        Me.TimerInterval = 300
    Else
        Me.TimerInterval = 0
        Me.lblSomeLabel.ForeColor = vbBlack
    End If
End Sub
'************* Code End *************

1998-2009, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer