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
906 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
Comment Utility
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
Comment Utility
0
 
LVL 32

Expert Comment

by:jadedata
Comment Utility
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
 
LVL 3

Expert Comment

by:DMurray
Comment Utility
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
Comment Utility
How do I create an autoexec macro? And how do I hide a form? Thanks
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Author Comment

by:indyng
Comment Utility
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
Comment Utility
>>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
Comment Utility
Thanks for the advice!
0
 
LVL 3

Expert Comment

by:DMurray
Comment Utility
Damn no points for me?

:(

DMurray
0
 
LVL 3

Expert Comment

by:DMurray
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now