Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2007, 10:36 AM
Registered User
 
Join Date: Mar 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Timer Control

I am trying to add a timer control to a form using ACCESS 2002. What reference to I need to include to have the Timer Control appear in the list of controls. I've used the Timer Control in Visual Basic, but not using ACCESS exclusively.
I can't seem to find it anywhere.
Can anyone make a suggestion?

 
Old March 12th, 2007, 04:12 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

joebob,

As far as I know, the Timer is not actually a control.
When you place a timer on the form, I think you are basically enabling the Timer event.
Then of course you add code to the timer event in your form.

If you want to use Timer functionality in your modules/classes, then I believe you can use the "Timer" function of the DateTime class. This returns a Single representing the number of seconds since midnight. Therefore you can use this in a loop to do something every X seconds.

Note:
Make sure you have a DoEvents in the loop somewhere to make sure you don't inadvertantly zap all the machines resources!
Code:
'The interval for the timer (in seconds).
Const INTERVAL = 10
'Stores the next time to fire.
dim fireTime as Single

'The terminator for the loop, set this to true to exit.
Dim exitLoop as Boolean

Do
 'If we have hit or passed the fireTime
 If Timer >= fireTime Then
  'Set the next time to fire by adding the interval
  fireTime = Timer + INTERVAL

  'Add code that you want to do on each interval here
 Else 
  'Do Nothing, good time to yield to the OS.
  DoEvents
 End If

Loop Until exitLoop = True
I hope this helps.

Best Regards,
Rob

 
Old March 12th, 2007, 07:59 AM
Registered User
 
Join Date: Mar 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Rob -
thanx so much for responding. This makes perfect sense. Doing more in native VB than ACCESS using VBA...I just thought along the lines of having to place a control onto a form to benefit from it's functions. This helps out a great deal, and I should be all set now.
Thanx again!

joebob

 
Old March 12th, 2007, 08:31 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

joebob,

Your very welcome, glad I could help.
If you need anything else then please ask.

Best Regards,
Rob






Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer control dipanjan22 ASP.NET 1.x and 2.0 Application Design 2 July 25th, 2007 12:00 PM
I need Coding for Timer Control Dhanapal ADO.NET 2 April 2nd, 2007 04:47 AM
Timer Control sankar_massoft General .NET 0 December 21st, 2004 11:53 PM
Can a non-visable control such as a timer be insta hamil VB.NET 2002/2003 Basics 2 July 26th, 2004 05:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.