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
922 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

696 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