Solved

Make label flash with different Background colors

Posted on 2000-05-12
4
1,256 Views
Last Modified: 2008-02-01
How is it possible to make a label background color change from one color to another creating a flashing effect on a form ? Do you use the form timer event, loop functions or what...

Thank you
0
Comment
Question by:fouchev
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
mcmonniesa earned 50 total points
ID: 2806169
Start by setting the label's "Back Style" to "Normal".  Next set the form's timer interval to a value (i.e., 1000 = 1 second, 100 = 1/10th of a second).  Then add code to the Form_Timer event like:

Private Sub Form_Timer()

   If lblFlasher.BackColor = vbRed Then
      lblFlasher.BackColor = vbBlue
   Else
      lblFlasher.BackColor = vbRed
   End If
   
End Sub

This sample should flash red and blue.  You can expand it to more colors or use an array of colors.
0
 
LVL 1

Expert Comment

by:mcmonniesa
ID: 2806174
Additionally the Form_Timer event acts like a continuous loop.  That is every time the interval hits (times out) the code is run.  To stop the timer, close the form or set it off in code:

    Me.TimerInterval = 0

0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2806177
Option Explicit

Dim FlashState As Boolean

Private Sub Form_Timer()

       FlashState = Not FlashState

       If FlashState = True Then
              Me!ctrl.BackColor = 255      ' Red
       Else
              Me!ctrl.BackColor = 65535  ' Yellow
       End If

End Sub  

Then set the Timer interval to what you like.

To trun off the flashing, set Timer interval = 0

Brian
0
 
LVL 4

Expert Comment

by:mberumen
ID: 2806186
you could also expand fouchev's code to occur whenever a condition is meet in your database... such as an error or update..

function sub flashlabel()
for counter=1 to 100 step 10

                         If lblFlasher.BackColor = vbRed Then
                            lblFlasher.BackColor = vbBlue
                         Else
                            lblFlasher.BackColor = vbRed
                         End If
next
                         
End Sub

'then  you could call the function as needed
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now