Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flashing text in a form 1

Status
Not open for further replies.

aaronjonmartin

Technical User
Jul 9, 2002
475
GB
Sounds stupid but is there anyway I can get the text displayed in a control on a form to blink or flash? I dont know VB so I would greatly appreciate thorough explanations. Thankyou very much in advance.

AAron
 
I thought flashing text went out of fad many years ago, because it was deemed to bring on epilepsy, or something like that.

One way to do it I guess would be to use the timer event assocated with the form, and then every even interval of the timer, make the text control visible; every odd cycle make it non visible. The net effect would be that the control would flash.

(a) Add a Label control to your Form and call it lblFlash. Set the caption property to the caption you want to see flashing.

(b) Set the Timer Interval property of the form to 250 (ie. quarter of a second; change this later as you like)

(c) Add the following code to the OnTimer event associated with the form:

Private Sub Form_Timer()
Dim F As Form: Set F = Me
F!txtFlash.Visible = Not F!txtFlash.Visible
End Sub

This will make the caption visible and non visible every alternate timer cycle; effectively flashing it.

There are probably other ways, though I cant think of any offhand; Personally, I don't like to overdo the use of the timer event.

Hope that this helps,
Cheers,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
 
Thanks for the help Steve

I tried to set the timer interval property but cant find out how to do it. When I look at the form properties there is no option to change the timer interval. could you re post a little more detailed as Iam quite inexperienced with access.

Aaron
 
Anybody know how to get a control to flash or blink the value it is displaying in a form. Would be a great help

Aaron
 
Hi Aaron,

I don't know if I'll be much help, but I'll try. You can follow Steve's instructions, but I use a variation on step (c). I'll steal part of Steve's post and tell you how I get a label (or text box) to flash.

(a) Add a Label control to your Form and call it lblFlash. Set the caption property to the caption you want to see flashing.

(b) Set the Timer Interval property of the form to 250 (ie. quarter of a second; change this later as you like) The Timer Interval is located on the form property Events tab. It is directly under the On Timer event.

(c) Add the following code to the OnTimer event associated with the form. (go into the properties of the form and the On Timer event is on the Events tab. Click on the elipses (the 3 dots at the right of the On Timer event)and click on code builder then add this code:
Code:
     If lblFlash.ForeColor = 65280 Then
        lblFlash.ForeColor = 255
     Else
        lblFlash.ForeColor = 65280
     End If
The colors I used were red and neon green. You can find the color numbers in the palette where you select text colors. The color number appears in the label property ForeColor under the Format tab.

I know enough about Access to be dangerous, but this works for me.

Thanks,
Joan

 
Aaron,
Hopefully you found that TimerInterval property (as per Joans instructions) and have something working. Let us know, Cheers,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
 
Joan,

Thanks for the help, it worked spot on. Just one quick question. I am using this on a control which displays a scheduled telephone call date, is there a way I could amend this code so that it only makes the dates that are equal to todays date flash and other dates that are before or after todays date just stay normal? Any help would be fantastic.

Aaron
 
Aaron,

I'm 'on the spot', and its a quickie, so if I'll hijack this from Joan, who I'm sure won't mind. We'll consider this a 'team effort'.

Simply modify the code as follows. I'll assume that you've adapted your control to be a Text box as opposed to a Label, and that this text box gets its value somehow (probably by virtue of it being bound to a table). Lets call it txtTelephoneCallDate.

The OnTimer event then becomes:

If txtTelephoneCallDate.ForeColor = vbBlue _
Or txtTelephoneCallDate < Date _
Or txtTelephoneCallDate >= Date + 1 Then
txtTelephoneCallDate.ForeColor = vbRed
Else
txtTelephoneCallDate.ForeColor = vbBlue
End If

This effectively prevents the flash if the TelephoneCallDay is not within the current date, by forcing the If statement down the 'then' path for other days.

Note also the use of the vb... color constants which make the program a little friendlier.

The reason I have a range checks against the date (as opposed to an equality check), is if the TelephoneCallDate field is held as a Date/Time field, then a time could be encoded as a qualifier to the date (eg. 10/10/02 10:29am&quot;). The range check will ensure that this date/time is matched within the appropriate 24 hours. Cheers,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
 
Steve101,

I tried your code but it didnt work. It didnt like the first OR statement. The error message I get is, &quot;Expected: line number or label or statement or end of statement&quot; any ideas?

Aaron
 
Steve101,

Sorry my mistake I had missed the underscores out of the code that is why I was getting that error message. However when I inputted the code correctly and went back into the form I got a Run Time Error, saying:

Run-time error '424':

Object required

Then when I clicked Debug, the following statement is Highlighted yellow with an error pointing to the last line.

If txtlblFlash.ForeColor = vbBlue _
Or txtlblFlash < Date _
Or txtlblFlash >= Date + 1 Then


 
Aaron,

In the code,

If txtlblFlash.ForeColor = vbBlue _
Or txtlblFlash < Date _
Or txtlblFlash >= Date + 1 Then

txtlblFlash should be the name of your control that is holding the date, not the name of the label. The reason your're getting an error is because labels cannot hold data so if you try to check data, eg. in the lines

Or txtlblFlash < Date _
Or txtlblFlash >= Date + 1

you will get an error.

Change txtlblFlash to the name of your control which is holding the date. If you want the label to flash as well then use the code with the below addition

If YourControlName.ForeColor = vbBlue _
Or YourControlName < Date _
Or YourControlName >= Date + 1 Then
YourControlName.ForeColor = vbRed
YourLabelName.ForeColor = vbRed
Else
YourControlName.ForeColor = vbBlue
YourLabelName.ForeColor = vbBlue
End If

Sorry to hijack it from you steve!

Hope that helps,

Cheers,

Pete

PS Steve, I'm a bit confused about why you used OR. Shouldn't it be AND?



 
Aaron,

Hope with Pete's help, you've resolved the problem. As I said in my post, because the flashing item is data as opposed to just a message, the control type should be a text box, as opposed to a label. Hense the problem you're having.

Pete,
Thanks for the assistance; as long as it gets the thread answered, thats what counts. No, the OR is right; think about it: If it is not the current data, then we always want to drive the logic down the same path (to prevent the flashing); the OR does just that. However, an additional nested IF statement might be used to achieve the same thing with some code redundancy but more clarity. The existing logic could also no doubt be inverted to use ANDs and NOTs and achieve the same effect.

Aaron,
If you havnt yet resdolved it, provide me an email address, and I'll send you a simple working example. If som let me know if its 97 or 2000 that you're using. Cheers,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
 
Steve,

I havent actually managed to solve it yet as it stands it stays blue all the time even if it displays todays date. I working example would be excellent Iam using 2000 and my email address is aaron@bluecannon.co.uk.

Cheers mate

Aaron
 
On its way mate, Cheers,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top