Stop Statement
Use a Stop statement to suspend execution of your procedure.
Syntax
StopNotes
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
In this tutorial:
- Visual Basic Fundamentals
- Visual Basic Development Environment
- Visual Basic Editor Window
- Relationship Between Access and Visual Basic
- Visual Basic Debugging Tools
- Working with the Watch Window
- Variables and Constants
- Variable and Constant Scope
- Declaring Constants and Variables
- Dim Statement
- Enum Statement
- Event Statement
- Private Statement
- Public Statement
- Static Statement
- Type Statement
- Collections, Objects, Properties, and Methods
- DAO Architecture
- ADO Architecture
- Referencing Collections, Objects, and Properties
- Use Exclamation Points and Periods
- Assigning an Object Variable-Set Statement
- Object Methods
- Manipulating Complex Data Types Using DAO
- Working with ADO Recordsets
- Functions and Subroutines
- Sub Statement
- Understanding Class Modules
- Property Let
- Property Set
- Controlling the Flow of Statements
- Do...Loop Statement
- For...Next Statement
- For Each...Next Statement
- If...Then...Else Statement
- RaiseEvent Statement
- Stop Statement
- With...End Statement
- Running Macro Actions and Menu Commands
- Executing an Access Command
- Trapping Errors
- Working with 64-Bit Access Visual Basic for Applications
- Using LongPtr Data Types
- Supporting Older Versions of Access
- Using LongLong Data Types