How to let certain TxtBoxes blink & change fore color?

G

Guest

Hi Everyone,

I have a form with about 50 TxtBoxes in it. Each TxtBox is to display a date
and the dates change with different condition. What I want to do is to let
certain Txtboxes blink and change the fore color when some specific date is
displayed in them.

I put this in my update CmdButton

If TxtBox1 = #certain date# Then
Me![TxtBox1].ForeColor = vbRed
Me.TimerInterval = 500
ElseIf TxtBox2 = #certain date# Then
Me![TxtBox2].ForeColor = vbRed
Me.TimerInterval = 500
......
..End If

The in my form's On Timer event I put

If TxtBox1 = #certain date# Then
Me![TxtBox1].Visible = Not Me![TxtBox1].Visible
ElseIf TxtBox2 = #certain date# Then
Me![TxtBox2].Visible = Not Me![TxtBox2].Visible
.......
..End If

Although TxtBox1 and TxtBox2 should blink and change the fore color with
certain condition, only the first one, i.e. TxtBox1, works. Can anyone tell
me how to do this? Thank you.
 
R

Rob Oldfield

Your immediate problem is with the use of ElseIfs - they will only ever
allow for one of the conditions to be true. So you're saying "If txtBox1 is
this date then do this... and then ignore all of the other conditions". It
would need to look more like...

If TxtBox1 = #certain date# Then
Me![TxtBox1].ForeColor = vbRed
Me.TimerInterval = 500
end if
If TxtBox2 = #certain date# Then
Me![TxtBox2].ForeColor = vbRed
Me.TimerInterval = 500
end if
....
End If

Second problem is that if you switch the visibility of the text boxes off
then you're going to generate an error when the cursor is in a text box when
it gets set to invisible.

Third (and probably most important) problem is that flashing text is (except
in a few exceptional situations) a bad idea. It's just bad interface
design. Do a search in Google for something like

user interface design "flashing text"

and you'll get heaps of references to support that (most of them about web
design, but the idea is the same).
 
G

Guest

Hi Rob,

I think you have solved my problem temporarily. Thank you very much.
Fortunately, my form is for display only and the error caused by inserting
the cursor in a TxtBox is least likely to occur. Anyway, I will do a research
on this issue as you suggest. Thank you.

Jeff

"Rob Oldfield" 來函:
Your immediate problem is with the use of ElseIfs - they will only ever
allow for one of the conditions to be true. So you're saying "If txtBox1 is
this date then do this... and then ignore all of the other conditions". It
would need to look more like...

If TxtBox1 = #certain date# Then
Me![TxtBox1].ForeColor = vbRed
Me.TimerInterval = 500
end if
If TxtBox2 = #certain date# Then
Me![TxtBox2].ForeColor = vbRed
Me.TimerInterval = 500
end if
....
End If

Second problem is that if you switch the visibility of the text boxes off
then you're going to generate an error when the cursor is in a text box when
it gets set to invisible.

Third (and probably most important) problem is that flashing text is (except
in a few exceptional situations) a bad idea. It's just bad interface
design. Do a search in Google for something like

user interface design "flashing text"

and you'll get heaps of references to support that (most of them about web
design, but the idea is the same).


Jeff said:
Hi Everyone,

I have a form with about 50 TxtBoxes in it. Each TxtBox is to display a date
and the dates change with different condition. What I want to do is to let
certain Txtboxes blink and change the fore color when some specific date is
displayed in them.

I put this in my update CmdButton

If TxtBox1 = #certain date# Then
Me![TxtBox1].ForeColor = vbRed
Me.TimerInterval = 500
ElseIf TxtBox2 = #certain date# Then
Me![TxtBox2].ForeColor = vbRed
Me.TimerInterval = 500
.....
.End If

The in my form's On Timer event I put

If TxtBox1 = #certain date# Then
Me![TxtBox1].Visible = Not Me![TxtBox1].Visible
ElseIf TxtBox2 = #certain date# Then
Me![TxtBox2].Visible = Not Me![TxtBox2].Visible
......
.End If

Although TxtBox1 and TxtBox2 should blink and change the fore color with
certain condition, only the first one, i.e. TxtBox1, works. Can anyone tell
me how to do this? Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top