3 second timer

Posted on 2011-04-25
Medium Priority
Last Modified: 2012-05-11
I have an Access database that sends mass emails out of Outlook.  Sometimes it fills up Outlooks sendmail box too fast.  I want to add a 3 second delay.  I have tried this and it locks up Access.  The Access/Outlook interface works fine.  Just trying to get a 3 second delay.  Thanks.

Set rs2 = db.OpenRecordset("qryMassEmailFinal")
If Not rs2.EOF Then rs2.MoveLast
Do Until rs2.EOF

' ***timer
Dim ldteEnd As Date
ldteEnd = DateAdd("s", 3000, Now)
While Now < ldteEnd
           Set MyOutlook = New Outlook.Application
           Set MyMail = MyOutlook.CreateItem(olMailItem)
            MyMail.To = rs2.Fields("email")
            MyMail.Subject = vubject
            MyMail.Body = vBody

Question by:Sasha42
LVL 58

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 total points
ID: 35462974
Paste the attached code into a standard module, then add


to your code where you want the pause to occur.

Public Function Wait(intSeconds As Integer) As Integer

    Dim datCurDateTime As Date
10  datCurDateTime = Now

20  Do Until DateDiff("s", datCurDateTime, Now) > intSeconds
30      DoEvents
40  Loop

End Function

Open in new window


Author Closing Comment

ID: 35463071

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 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