Timer Event/Blinking

  • Thread starter Thread starter LarryP
  • Start date Start date
L

LarryP

I have a form with subforms on tabs. Main form has a
control (let's call it txtXXX) with a numeric value, and
two labels -- one says "OK To Ship," the other says "Do
Not Ship." On form open, if the txtXXX contains a zero,
the former is visible; if it contains >0, the latter is
visible.

Events in the subforms can change the value of txtXXX, OR
(key point) trigger code that changes the value of
txtXXX. Of course whenever txtXXX changes I want the flag
to change if appropriate. Under some circumstances I
could do that with the AfterUpdate event, but when the
change comes from a procedure that event apparently
doesn't fire, so I've set up a timer event to test the
value of txtXXX every 1000 milliseconds and change the
visible label if appropriate. Problem is, it creates a
visible flickering effect that I'd like to get rid of.
Anybody know how I might do that, or have another way I
can achieve my goal without using a timer event? (Upping
the timer interval is not an option, by the way; customers
want to see that flag change almost instantly when they
make a related change in one of the subforms.)
 
Larry,

It's probably flickering because the Timer event is causing
the form/control to be repainted.

Couldn't you create a public function that sets the field
you want visible or whatever and then call it from whatever
bits of code cause an appropriate change in the forms
recordset?

There are ways to see if the recordset has changed (Dirty
Event/Property) but they're Form level, the whole recordset,
rather than Field/Control level things.
 
LarryP said:
I have a form with subforms on tabs. Main form has a
control (let's call it txtXXX) with a numeric value, and
two labels -- one says "OK To Ship," the other says "Do
Not Ship." On form open, if the txtXXX contains a zero,
the former is visible; if it contains >0, the latter is
visible.

Events in the subforms can change the value of txtXXX, OR
(key point) trigger code that changes the value of
txtXXX. Of course whenever txtXXX changes I want the flag
to change if appropriate. Under some circumstances I
could do that with the AfterUpdate event, but when the
change comes from a procedure that event apparently
doesn't fire, so I've set up a timer event to test the
value of txtXXX every 1000 milliseconds and change the
visible label if appropriate. Problem is, it creates a
visible flickering effect that I'd like to get rid of.
Anybody know how I might do that, or have another way I
can achieve my goal without using a timer event? (Upping
the timer interval is not an option, by the way; customers
want to see that flag change almost instantly when they
make a related change in one of the subforms.)

My first inclination would be to wrap any code that will change the
value of txtXXX in a single function such that all other locations call
this function. Then that function would also update the labels'
visibility.

However, if that's really not practical, it may be able to solve the
problem by adjusting the code in your Timer event procedure. I'd guess
if you're getting flickering it's because you're setting the Visible
properties every time the event fires, regardless of whether they are
already set the way they should be. Is that the case? If so, maybe you
could change the code to something like this:

If Me.txtXXX = 0 Then
If Me.lblOKToShip.Visible = False Then
Me.lblDoNotShip.Visible = False
Me.lblOKToShip.Visible = True
End If
Else
If Me.lblOKToShip.Visible = True Then
Me.lblOKToShip.Visible = False
Me.lblDoNotShip.Visible = True
End If
End If

That's assuming, of course, that you don't already have it set up like
this.
 
That did it. I did have it in a separate public sub, but
was setting the visibility each time instead of only as
needed. Thanks, Dirk.
 
Back
Top