Many thanks arnelgp. Let me repeat the problem and suggest a solution based on your suggestion.
The problem is created when a user enters an appointment in his appointment form and this appointment is not visible in the appointment form of the other users. The simple solution is to refresh the appointment form every few minutes (can be user definable), but it would not be a good idea to refresh the form when the user is doing work on the form.
Let's say that I want to refresh every 5 minutes, assuming the user is not doing any work on the form. One solution which I thought of is to use arnelgp code above to check for movement every say 5 seconds and have a counter for every 5 seconds that has elapsed without movement. If this counter reaches 100 (the number of 5 second intervals in 5 minutes) than I do the form refresh and set the counter to 0.
I would modify arnelgp's code so that once the movement is detected the TimerInterval is set to something very small such as 100 so that the Stationary code is executed immediately and at this point the TimerInterval is set again to 5 seconds. In other words, no need to wait for 5 seconds when movement has been detected. I include below what I mean,
Code:
If (cur_point.x <> last_point.x) Or (cur_point.y <> last_point.y) Then
With lblMoving
.Caption = "Moving"
.ForeColor = 1643706
Me.TimerInterval = 101 '*** Added code
End With
Else
With lblMoving
If Me.TimerInterval = 101 Then '*** Added code
Me.TimerInterval = 5000 '*** Added code
End If '*** Added code
.Caption = "Stationary"
.ForeColor = 2316088
End With
End If
Also, you are correct about resetting the Timer on exit of specific form and enabling it when the user returns.
Many thanks arnelgp. Let me repeat the problem and suggest a solution based on your suggestion.
The problem is created when a user enters an appointment in his appointment form and this appointment is not visible in the appointment form of the other users. The simple solution is to refresh the appointment form every few minutes (can be user definable), but it would not be a good idea to refresh the form when the user is doing work on the form.
Let's say that I want to refresh every 5 minutes, assuming the user is not doing any work on the form. One solution which I thought of is to use arnelgp code above to check for movement every say 5 seconds and have a counter for every 5 seconds that has elapsed without movement. If this counter reaches 100 (the number of 5 second intervals in 5 minutes) than I do the form refresh and set the counter to 0.
I would modify arnelgp's code so that once the movement is detected the TimerInterval is set to something very small such as 100 so that the Stationary code is executed immediately and at this point the TimerInterval is set again to 5 seconds. In other words, no need to wait for 5 seconds when movement has been detected. I include below what I mean,
Code:
If (cur_point.x <> last_point.x) Or (cur_point.y <> last_point.y) Then
With lblMoving
.Caption = "Moving"
.ForeColor = 1643706
Me.TimerInterval = 101 '*** Added code
End With
Else
With lblMoving
If Me.TimerInterval = 101 Then '*** Added code
Me.TimerInterval = 5000 '*** Added code
End If '*** Added code
.Caption = "Stationary"
.ForeColor = 2316088
End With
End If
Also, you are correct about resetting the Timer on exit of specific form and enabling it when the user returns.