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

Trying to create an on-screen countdown timer in Access 2007

Status
Not open for further replies.

MacroScope

Programmer
Jul 17, 2010
286
US
I'm writing a database for an insurance company that has as its core business model responding with a quote within 12 minutes. The company takes this very seriously, and wants an on-screen timer integrated into the form as the quote is being written.

I already have an elapsed time timer, which simply sets the current time as the quote is initiated, and which subtracts that value from the current time as it is printed, leaving the elapsed time as a record for admin to review.

In this case, they want an actual timer, again initiated along with the quote, but which actively shows the seconds and minutes ticking by, one by one.

I've considered using the form timer event, but it seems awkward since there are 4 forms for 4 different types of vehicles for which policies are sold.

I'm looking for suggestions. It's a split db, and I thought about setting one global timing signal on the server by including a form and timer event on the backend, but I'm not sure what that global signal would consist of, and how it might be sent to individual work stations.

I don't see the actual representation of time as a problem, simply requiring the same thing I have in elapsed time now, a subtraction of start time from current time at one second intervals triggered by the OnTimer event (unless there's a better way).

I'm open to any ideas anyone has on a good way to create this.

Thanks to all.
 
How are ya MacroScope . . .
MacroScope said:
[blue] ... I thought about setting one global timing signal on the server by including a form and timer event on the backend ...[/blue]
Bad Idea. The last thing you need is the backend pinging all frontends or vice versa. To be sure ... this is a function for the [blue]frontend[/blue]. Its possible to have 1 forms timer event handle all 4 forms. Its simply a matter of the processing time for all 4 forms to be less than 1sec. With the speed of todays processors I doubt that will be an issue.

I have code ready to give ya, there's just one question you havn't answered: [blue]What do you intend to do when the 12min are up?[/blue]

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I don't want it to do anything except perhaps to change color to red and start counting in the other direction. It's a way for the order processor to visually see where s/he is at that moment.

I've already written another routine that runs once a minute. It does a time comparison between Time() and the time unprinted quotes were started. After 10 mins a warning pops on the processor's screen saying something like, "You started a quote for [Name] 10 minutes ago. Please finish the quote immediately or ask for help."

It pops again every minute thereafter. Also, if it goes beyond 12 minutes a message pops on Admin screen saying "Username() started a quote for [Name] 12 minutes ago and has not finished it yet."

That way they can keep a close eye on how long people are taking, but it really has nothing to do with the countdown timer. That is just to keep the person handling the quote alert to the time so they're more likely to get it out in time.

Rather than have two timer routines I think it's smarter to add a counter somewhere else every second, and when it reaches 60 the other routine runs as well, but I'm open to suggestions on how to get both to work together.
 
MacroScope . . .

What I did was setup a blank form with the [blue]Timer Interval[/blue] set to 1sec (1000). This is the common timer. It can be open hidden.

To handle the four forms I setup an array in the [blue]declarations section[/blue] of a module:
Code:
[blue]Option Compare Database
Option Explicit

Public tmrAry(1 To 4) As Long[/blue]
To start the timer each form writes the number of seconds to a corresponding element in the array. Example for 12min:
Code:
[blue]tmrAry(1) = 720[/blue]
The code in the common timer [blue]On timer[/blue] event handles the rest. Note: [blue]you![/blue] substitute proper names in [purple]purple[/purple]:
Code:
[blue]   Dim frmName As String, ctlName As String, x As Integer
   
   For x = 1 To 4
      frmName = Choose(x, "[purple][b]Form1[/b][/purple]", "[purple][b]Form2[/b][/purple]", "[purple][b]Form3[/b][/purple]", "[purple][b]Form4[/b][/purple]")
      ctlName = Choose(x, "[purple][b]txtTmr[/b][/purple]", "[purple][b]txtTmr2[/b][/purple]", "[purple][b]txtTmr3[/b][/purple]", "[purple][b]txtTmr4[/b][/purple]")
      tmrAry(x) = tmrAry(x) - 1
            
      If IsOpenForm(frmName) Then
         Forms(frmName)(ctlName) = Format(TimeSerial(0, 0, tmrAry(x)), "nn:ss")
         If tmrAry(x) = 0 Then DoCmd.Close acForm, frmName, acSaveYes
      End If
   Next[/blue]
Currently I have it set to close any of the four forms when they countdown to zero. You can modifiy as necessary.

The following support routine is needed to tell if a form is open. Post it in a module in the modules window:
Code:
[blue]Function IsOpenForm(frmName As String) As Boolean
   
   If CurrentProject.AllForms(frmName).IsLoaded Then
      'if form is loaded and not in design view, then ok!
      If Forms(frmName).CurrentView > 0 Then IsOpenForm = True
   End If
   
End Function[/blue]
Thats it ... I've attached a sample db below in 2003 format.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
 http://www.4shared.com/document/x-J5Wfbs/CommonTimer.html
Thanks, AceMan. I know you must have tested this or you wouldn't have put it in an .mdb file. However, I couldn't get it to run. The code failed on the word "Format". How is it initiated? I never saw any digits displayed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top