Solved

Make label flash with different Background colors

Posted on 2000-05-12
4
1,267 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

911 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

23 Experts available now in Live!

Get 1:1 Help Now