Solved

Is there a way to run a VBA code automatically at a specific time intervals without using the On Timer on a form?

Posted on 2003-12-02
10
911 Views
Last Modified: 2007-12-19
Hi Experts,

Is there a way to run a VBA code automatically at a specific time intervals without using the On Timer on a form?

I have a VBA code  that activates the send/receive of Outlook. The VBA looks for emails with a specific subject line and reads it into a table. I want to run the VBA in the background regardless if a form is open or not. That's why I do not want to place the VBA code in the On Timer of a form. Is this possible and how can it be accomplished?

Thanks
0
Comment
Question by:indyng
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 23

Expert Comment

by:heer2351
ID: 9862317
It is doable using the SetTimer API but it is not simple.

I would recommend opening a hidden form with a timer automatically when the database opens.
0
 
LVL 7

Expert Comment

by:wsteegmans
ID: 9862332
0
 
LVL 32

Expert Comment

by:jadedata
ID: 9862336
Hey indyng!

  Yes.  Set the Timer Inteval on the for to an appropriate number of milliseconds

  Use the Form_Timer event to trigger a look at the system clock,... Time()

  if the Time() is right, run your function/subroutine
regards
Jack
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 3

Expert Comment

by:DMurray
ID: 9862339
I'm not aware of any other way.

Why not have a timer on a hidden form in the background, so no one can see it.

I have timers that do similiar things, what I do is when my database opens, in my autoexec macro I get it to open a form "startup" in hidden mode. Therefore, user cannot see it, but the timers still run.

DMurray
0
 
LVL 1

Author Comment

by:indyng
ID: 9862818
How do I create an autoexec macro? And how do I hide a form? Thanks
0
 
LVL 1

Author Comment

by:indyng
ID: 9862822
If the focus is not on the hidden form will the On Timer still initiate? Thanks
0
 
LVL 23

Accepted Solution

by:
heer2351 earned 500 total points
ID: 9862845
>>How do I create an autoexec macro? And how do I hide a form?
Goto the macros tab
Create a new macro
Make it open your form (Action: OpenForm, windowMode = Hidden)
Call this macro AutoExec it will run each time the database is opened.

>>If the focus is not on the hidden form will the On Timer still initiate?
Yep the timer will still work.

0
 
LVL 1

Author Comment

by:indyng
ID: 9862916
Thanks for the advice!
0
 
LVL 3

Expert Comment

by:DMurray
ID: 9863390
Damn no points for me?

:(

DMurray
0
 
LVL 3

Expert Comment

by:DMurray
ID: 9863397
ooops

Sorry, I thought I had originally suggested the hidden form. But I note that Heer did originally. Sorry for that..

DMurray
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question