Flashing control

Peter Bellamy

Registered User.
Local time
Today, 17:23
Joined
Dec 3, 2005
Messages
295
Can anybody suggest some simple code that will change the colour of a control about once a second?

Cheers
 
Once a second is pretty fast, but -

Set the form's timer interval to 1000 (1000 milliseconds equals 1 second)

Then in the form's Timer Event (in the VBA window) put:
Code:
If Me.YourControl.BackColor = 16777215 Then
   Me.YourControl.BackColor = 65535 
Else 
   Me.YourControl.BackColor = 16777215
End If

Change the color numbers to whatever you want. I have it white and yellow.
 
Thanks Bob,
That's interesting, I have never used a forms timer control !
Will anything else on the form be effected by the timer?

peter
 
Shouldn't be. But, if you try to use the VBA window while the form is "open" and in form view (not design view), it will play havoc with you entering code (things will backspace suddenly, etc.) so you just want to make sure it is either closed or in design view when you are working on code.
 
I have tested and see how it works, just the control is effected.
I changed it to use BackStyle instead of colour, which makes it look like it is going on and off.

Thanks
 
I have tested and see how it works, just the control is effected.
I changed it to use BackStyle instead of colour, which makes it look like it is going on and off.

Thanks

You could also have simply used Visible
Code:
Me.ControlName.Visible = Not Me.ControlName.Visible
Which would have it flashing on and off.
 
Yes but BackStyle keeps the outline instead of making it dissappear completely.
I am imitating a LED flash as an 'aid' for the form filler.

peter
 

Users who are viewing this thread

Back
Top Bottom