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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CountDown Timer in form - FLASHING

Status
Not open for further replies.

wkendrvr

Programmer
Joined
Apr 25, 2002
Messages
29
Location
US
I am having an interesting problem. When I update the unbound field in a form with the remaining time, it flashes. Is there anyway to eliminate this? (I reduced it by counting by 5's, but I would like to have it countdown without having to do that)

Here is the code:

Private Sub Form_Timer()
Dim start
Dim timer_int
Dim current
Dim elapsed
Dim time_left
dim start

Me.TimerInterval = 0

timer_int = 30

start = Fix(Timer())

timer_loop:

current = Fix(Timer())

elapsed = Fix(current - start)

time_left = timer_int - elapsed


If (time_left / 5) = (Fix(time_left / 5)) Then Me!Text3 = "Application will close in " & time_left & " seconds."


If elapsed >= timer_int Then DoCmd.Quit

GoTo timer_loop
End Sub


(and anyone looking to count by a number, the calculation of x/y = fix(x/y) works nicely. ;-)
 
Aha! Got it! (sorta)


I created another control box with a height of 0" and a width of 0" and then added


If (time_left / 5) = (Fix(time_left / 5)) Then
Me!Text3 = "Application will close in " & time_left & " seconds."
Text11.SetFocus
Form.Repaint
End If


I get a slight flicker, but it is at least readable now. Now if I could get it not to flicker at all...

 
What is the timer interval set to?

I think the interval is in MILLI seconds, so an interval 0f 1000 causes the timer routine to fire every second. This is generally more than is desireable for an auto shutdown routine (which this appears to be).

Why are you looping in this procedure? The more mormal process is to check some value (e.g. current control) and it has not changed, increment a counter. When / If the counter reaches a threshold, do the exit routine.

All together, this seems 'un-friendly'. I think the HELP system has better examples than this, perhaps a visit to there is useful.

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
The looping in the procedure is to give the user a countdown. I also added a progress bar to this and it works well. What this is for is the final form to be displayed before booting a user for maintenance. A more user friendly form is displayed for 5 min prior to this.

The fix above stopped the flickering (which was the line where the text was being displayed being selected).
 
Still weird -to me.

What is the timer event FOR, if not to do the timing? Looping within a timer event, to do a countdown, is just 'backwards' to my thought process.

I guess it is just one of the many ways one could do it, just not one I would think of.

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
The timer event is only used to allow enough time for the form to open. The form is being updated in the example above every 5 seconds. IF I just used the timer event I still would have to keep track of how many times it has iterated and I decided to use real time (stead of the timer event) Also, the timer event is used once (for the reason of the form not opening). It is triggered, then reset to 0. Now, if I did it using the timer event, I found that it wasn't quite accurate timewise, and I still had the flashing issue...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top