Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    2

    Unanswered: Multiple Timers in a form

    I am trying to create 4 stopwatches on a form which can be stopped and started independantly using the keys 1 to 4 (ascii 49 to 52). I can get one working however i am restricted as access only lets you have 1 timer per form.

    I tried subforms however i cannot use the keys then as the subform need the focus.

    can anyone help

    regards

    Spike

  2. #2
    Join Date
    Feb 2004
    Posts
    199
    in Access form you can have only one timer on one form.
    To solve your problem you have to one timer and arange your code to call your timer subroutines by form's timer event
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by Kakha
    in Access form you can have only one timer on one form.
    To solve your problem you have to one timer and arange your code to call your timer subroutines by form's timer event
    Not necessarily ... If use you the API timer event you could do that ... The problem being making the callback function to handle the timer event ... I think you could do something with a hidden control and co-op one of it's events.

  4. #4
    Join Date
    Feb 2004
    Posts
    2
    can you expand on your explanations please.

  5. #5
    Join Date
    Feb 2004
    Posts
    199
    wich one
    if you aren't familiar with API use my way

    use Form's timer and run it with small interval (for example if you need 3 timers with 10/5/3 sec intervals, set the interval to 1 sec=1000ms)
    then make 3 subroutines in your form
    Timer10/Timer5/Timer3 and add a funtion in your code

    Code:
    Function ServeTimer(Ticks as Integer, Interval as Integer) as Boolean
    Ticks=Ticks+1
    If Ticks>Interval Then
         Ticks=0
         ServeTimer=True
    Else
         ServeTimer=False
    End If
    End Funtion
    Add Global variables in your Form
    Code:
    Dim Ticks10 as Integer, Ticks5 as Integer, Ticks3 As Integer
    Dim Enable10 as Boolean, Enable5 as Boolean, Enable3 as Boolean
    Than in Timer Event Code add

    Code:
    If Enable10 then
       If ServeTimer(Ticks10,10) Then Call Timer10
    End if
    If Enable5 then
       If ServeTimer(Ticks5,5) Then Call Timer5
    End if
    If Enable3 then
       If ServeTimer(Ticks3,3) Then Call Timer3
    End if
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •