MS-Access / Getting Started

Stop Statement

Use a Stop statement to suspend execution of your procedure.

Syntax

Stop

Notes

A Stop statement has the same effect as setting a breakpoint on a statement. You can use the Visual Basic debugging tools, such as the Step Into and the Step Over buttons and the Debug window, to evaluate the status of your procedure after Visual Basic halts on a Stop statement. You should not use the Stop statement in a production application.

While...Wend Statement

Use a While...Wend statement to continuously execute a block of statements so long as a condition is true.

Syntax

While <condition>
    [<procedure statements>]
Wend

Notes

A While...Wend statement is similar to a Do...Loop statement with a While clause, except that you can use an Exit Do statement to exit from a Do loop. Visual Basic provides no similar Exit clause for a While loop. The <condition> is an expression that Visual Basic can evaluate to True (nonzero) or False (0 or Null). Execution continues so long as the <condition> is true.

Example

To read all the rows in the tblCompanies table until you reach the end of the recordset, enter the following in a function or sub:

Dim dbContacts As DAO.Database
Dim rcdCompanies As DAO.RecordSet
Set dbContacts = CurrentDb
Set rcdCompanies = dbContacts.OpenRecordSet("tblCompanies")
While Not rcdCompanies.EOF
    <procedure statements>
    rcdCompanies.MoveNext
Wend
[Previous] [Contents] [Next]