Link to home
Start Free TrialLog in
Avatar of a260148
a260148Flag for United States of America

asked on

Access VBA Timer Stops after a few hours

I have a computer that has an app that has an on timer event. The computer is used for this only. The computer gets locked and the screen saver eventually comes on.
The timer continues to fire for up to about 3 hours... then it just stops.
When i saw that it stopped, i unlocked the PC, and the app was still open on the screen, but the timer wasn't running any longer. Once I closed the app, and re-opened, the timer started again and worked fine.
Any suggestions on why the timer would have stopped, and how I can prevent this from happening. I need the timer to continue running in 12 hour increments, even if the PC is locked and Screen Saver activated.
Thanks
a260148
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of a260148

ASKER

Ok, thanks for your replies...
capricorn1:
As this is a machine that everyone uses... they don' t have admin rights on it... therefore I can't see the "Screen Saver" tab on the Properties menu. I did however check the "Powe Options Properties" under the Control Panel, and "Turn Off Hard Disks" and "system standby" are both set to Never. That was my first thought also... but apparently all PC's in our company automatically default to these options.

wizengamot:
Not sure what you mean... when you say "I would actually code a timer object myself in this case.  Create a loop that loops once per second. " You talking about making a timer in some other app? I only have MS Access and VBA at my disposal, and using any VBA stops after a certain amount of time.
Avatar of wizengamot
wizengamot

Well, if VBA actually stops to function altogether that is something that I am not sure I can solve.  The way I read your answer was that the Timer Object stopped to function.  The timer is part of the control suite that you have access to in the toolbox.  

As far as coding my own timer, you can do this in VBA as well to the best of my knowledge.  I am not sure what version of access you are using but anything 2000 and up should be able to make a call to the WIN32 API.  This would be the same as doing a Win32 API call in any other language.  The URL: http://support.microsoft.com/kb/210219 does not relate directly to what your doing but it does show syntax for declaring the API and the code I put in my first post can be substituted and used in the same manner.  Then you create a loop like this:

'this would be an infinite loop, this is what you want.
Do Until True = False
    'code that compares your timer and executes your code when you want it to.
     'code to count the clock
    NumberOfSeconds = NumberOfSeconds + 1
    Sleep 1000
Loop
Avatar of a260148

ASKER

Thanks for your reply... So your saying instead of using the "On Timer" event at all... just having the code continuously loop. Makes sense, but i'm not if it is actually just the "On Timer" event that stops after some amount of time... or if its VBA just suppends all together.

I can't find anything on the web about VBA suspending... but that is what seems to be happening... after right about 3 hours.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of a260148

ASKER

All, I re-started the app, and it has been running for 12 hours with not stopping of the Timer or VBA. Not sure why it stopped all the sudden on my first couple attempts? I didn't change any of the settings on the PC. I did however change a little of the Code. All i did different was instead of Dimming a RS, I used a Run SQL on timer. Not sure why or if this is what made the difference... but in any doubt, seems to be working fine now. Thanks to everyone for there input.
> Not sure why or if this is what made the difference

You probably didn't clean up:

  Set rs = Nothing

All objects _must_ be set to Nothing before exiting the function or you eat up memory slowly but surely.

/gustav