A: 

In answer to your questions:
1) Form_ Current will always run whenever you switch records. No choice. So the next best option is to move the call to CenterPoint to another event. I would use the form timer event, and reset the timer every time you go through Form_ Current, when the timer runs out, it will fire CenterPoint off.

Private Sub Form_Current()
    Me.TimerInterval = 10000
End Sub

Private Sub Form_Timer()
    CenterPoint
End Sub

2) If you are using the form timer event, you probably don't need this code any more; however,

Private Sub Form_Current()
Dim l_Start As long 
Dim l_Delay As long 
Dim l_endTime As long 'or integers - time is returning the number of seconds 
                      'since midnight, not a real... this may be the source 
                      'of your problem

    l_Delay = 1000 ' I didn't see you set s_Delay any where
    l_Start = Timer
    l_endTime = l_Start + l_Delay 'lets do the calculation only once.

'This might break down if the user switch records just before midnight
'(never ending loop)
'    Do While Timer < l_endTime 
'        DoEvents
'    Loop

    'Instead I would do this
    Do While (Timer <= l_endTime) _
                and (l_start <= timer)
        DoEvents
    Loop

    CenterPoint

End Sub
CodeSlave
A: 

Another possibility would be to keep the call in the OnCurrent event, but use a time flag outside the OnCurrent to determine whether or not to call the subroutine.

  Static s_Start As Single
  Dim s_Delay As Single

  If s_Start = 0 Then
     s_Start = Timer
  End If
  If Timer > s_Start + s_Delay
     Call CenterPoint
     s_Start = 0
  End If

Now, that's air code, so I may have a mistake or two in it, but the idea is that you run the code only once the delay has expired. And once it's expired, you set the start time back to 0 so that counter will start over again.

The result is that the call to CenterPoint will happen only on those OnCurrent events that happen after your delay has expired.

--
David W. Fenton
David Fenton Associates

David-W-Fenton

related questions