Runtime error 2118 - on timer event

Danick

Registered User.
Local time
Today, 18:29
Joined
Sep 23, 2008
Messages
371
I have a main form which I set a timer to requery to an unbound text box called "LocalTime" every 60 seconds

Code:
Private Sub Form_Load()
Me.TimerInterval = 60000
End Sub

Code:
Private Sub Form_Timer()
Me.LocalTime.Requery
End Sub
This works fine until the user edits something in a subform.
I tried to fix it by running Me.Dirty before the event, but it is still not working.
Code:
If Me.Dirty Then Me.Dirty = False
Right now, I am using a work around by just putting a command button to requery the local time when the user presses the button.
Code:
Me.LocalTime.Requery


But it would be nice if I could get this timer to work. Any ideas?
 
What do you have as the control source of the LocalTime control?
 
This works fine until the user edits something in a subform.
What does this mean? What fails? How does it fail?

One thing you could try is use an unbound textbox, and explicitly set the value on the timer event, rather than requery it, like...
Code:
Private Sub Form_Timer()
   me.txtLocalTime = Format(Now(), "hh:nn")
End Sub
...but my 2c would be, don't bother with a timer in your application. Running a timer is a pain, it doesn't add value to the data, it can cause screen flicker, it can terminate pending edits, and a user can put a clock on their Windows Task Bar if they need a visible timer.
hth
 
What do you have as the control source of the LocalTime control?

I'm using a function that calculates UTC. Details here:
Code:
http://www.excelfox.com/forum/showthread.php/542-Get-standard-GMT-time-from-the-system-using-vba

I use a field called CompanyTimeZone that will display the local time where the company is located.

Code:
=DateAdd("h",([CompanyTimeZone]),(Local2GMT(Now())))


This works fine so that the user can see the local time of the company they are trying to contact without using other sources like time and date sites, etc..
So when the user loads the form, it initially shows the time at that client's location. But then it doesn't update itself unless you close/re-open the form. So the timer was nice added feature although not really necessary and just using a command button for now.

If the timer is really not a good solution, I'll probably get rid of it altogether.
 
You could could set the value of the LocalTime textbox without using a Requery. Just have the code set it directly.
 
You could could set the value of the LocalTime textbox without using a Requery. Just have the code set it directly.

I do have the unbound text box set directly. But it only works when the form initially opens. The text box doesn't update itself while the form is open. And when the user is updating any field in the subform, the runtime error shows up as the field they are working on has not yet been saved yet. And I don't want to try to save the record before the timer.

So I guess I'll just stick with the manual command button for now...
 
...but my 2c would be, don't bother with a timer in your application. Running a timer is a pain, it doesn't add value to the data, it can cause screen flicker, it can terminate pending edits, and a user can put a clock on their Windows Task Bar if they need a visible timer.
hth


Hi Markk

The more I think about it, the more I'm leaning toward getting rid of the timer. Thanks for you comments.
 
Your choice but I suspect you could get it to update without the error.
 

Users who are viewing this thread

Back
Top Bottom