A Do…While loop lets you repeat code while a condition is true, or until it is true. In this video, learn how to repeat a task using a Do…While loop.
- [Instructor] When you create a Access VBA subroutine,…you expect it to take date from a data source,…transform it in some way,…and change the database or display the result.…Sometimes, however, you will want your VBA code to run…while a condition is met.…When you want a segment of your code to repeat…while a specific condition is true,…or to go until a specific condition is true,…you can use a Do While or Do Until loop.…I'll demonstrate how to use both of them in this movie.…
I've opened the course database…and I need to get into the Visual Basic Editor,…so I'll press Alt + F11.…Now that I'm here, I can insert a code module.…So I'll go to the Insert menu,…click Module, and there we go.…The first thing I'll do is count up the total quantity…of items ordered from the orders table…while it is less than 25.…So if I reach 25 or higher, then we will stop adding.…
I will call my subroutine Sub DoDemo,…and I'm not passing any arguments to it,…so I will have just an open and close parentheses,…and Enter to give myself some white space…
- Working with macros
- Running a VBA procedure
- Debugging VBA code
- Defining variables, constants, and calculations
- Displaying a calculated result in a message box
- Repeating tasks with loops
- Manipulating database objects
- Adding, editing, and deleting records
- Looking up values in a table
- Automating processes with macros
Skill Level Advanced
What you should know1m 38s
1. Introduction to Visual Basic for Applications
2. Define Variables, Constants, and Calculations
3. Add Logic to Your VBA Code
4. Debug Your VBA Code
5. Manipulate Database Objects Using DoCmd
6. Read and Manipulate Table Data
7. Manipulate a Database Using the Application Object
8. Control Forms and Reports Using the Me Object
9. Automate Processes Using Macros
Next steps1m 7s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.