Microsoft KB Archive/210182

= ACC2000: How to Create a Function That Pauses Program Execution =

Article ID: 210182

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210182



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
This article shows you how to create a sample user-defined function called Wait, which you can use to delay program execution for a specified period of time. You can call this function from any form or report event procedure or from a RunCode macro action.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.



MORE INFORMATION
To create the sample user-defined Wait function, open a new module and enter the following code: '**********************************************************  ' Declarations section of the module '**********************************************************

Option Explicit

'=================================================================== ' NOTE: In Visual Basic for Applications the unit of greatest precision ' is seconds. Therefore if the Timer is set to wait one second, the ' result could be a delay of anywhere from 0 to 1 second. If a higher ' degree of precision is required, another option is to use the Timer ' event of the form which has the ability to trigger every 1000th of a ' second. '====================================================================

Function Wait (Delay As Integer, DispHrglass As Integer)

Dim DelayEnd As Double DoCmd.Hourglass DispHrglass

DelayEnd = DateAdd("s", Delay, Now) While DateDiff("s", Now, DelayEnd) > 0 Wend DoCmd.Hourglass False

End Function

To test this function, type the following line in the Immediate Window, and then press ENTER: ?Wait(5,1)

Additional query words: inf

Keywords: kbhowto kbprogramming KB210182

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.