3 second timer

Posted on 2011-04-25
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 56

    Accepted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    759 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