Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 September 26th, 2005, 11:23 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default Automatic Timed Event

Hi,

Does anyone know how to start a timed event in VBA? I am writing a program and the specs call for the program to go out to a folder at a specific time, and search for any new files to be loaded. I can load the files without a problem. The trick is, how do I get Access to run the Sub at for instance 1:15pm?

Anyone have any ideas?

Thanks

Mike

Mike
EchoVue.com
__________________
Mike
EchoVue.com
 
Old September 27th, 2005, 11:37 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hiya,

   Okay, here is what you do:

Create a form and hide it.
Set the form's Visible property to False so that you can't see it when it opens.
Open the form when the application is opened.
On the form's Timer Event, you want to place code that goes out and checks the current time, like every 30 mins or so.
If the time is >= your update time (AND <= about 45 mins after your update time), then run your code that goes out and does your update.

The code might look like this:

Sub Form_Load()
   Me.TimerInterval = '30 seconds = 30000, so do the math
End Sub

Sub Form_Timer()
   Dim curTime As String
   Dim upTime As String

   curTime = cDate(Time())
   upTime = #13:15:00:00#

   If curTime >= upTime Then
     'call your update code
   End If

'etc

Someone help with the syntax. I don't have time today to test this.

Anyway, conceptually, this will do it.






mmcdonal
 
Old September 27th, 2005, 11:55 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi Mike,

Long time no speak!! Thanks, I found a different solution last night, but I like this one as well. I just found out from the person I am designing the application for that he would like it triggered on the Form_Load event, so I'll have to store this one in the "Future Use" folder.

Thanks again,

Mike

Mike
EchoVue.com
 
Old September 27th, 2005, 11:59 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I use the on load event to update records through the flesystemobject as well. I also use it to transfer tables from SQL for local OLAP. This can take some time and make the form seem like it is taking a longer time to load.

You may also want to put an update button on the form in case it is open for a long time, you can refresh it.

mmcdonal
 
Old September 27th, 2005, 12:01 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Good Advice! Thanks

Mike
EchoVue.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Timed alerts. jpool Visual Basic 2005 Basics 4 June 28th, 2008 09:26 AM
TIMED response.redirect misskaos Classic ASP Basics 2 December 9th, 2006 08:13 PM
Timed Executable KennethMungwira Beginning VB 6 1 July 28th, 2006 10:55 AM
Tool Has Timed Out m_gorbani ASP.NET 2.0 Professional 1 March 14th, 2006 07:07 AM
What if Session Timed Out?? MAtkins General .NET 2 January 23rd, 2005 12:26 PM





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