2 Loops in VBA

A loop is a control structure that permits repetition. In other words, any code enclosed by a loop executes repeatedly. While loops are very useful programming constructs, they can also be “abused” by developers who think more in procedural terms than SQL.

For example, in Access, one can right a loop to add up the price of all items in an order. However, it is much more efficient to use an SQL query to achieve the same result. In other words, in Microsoft Access, it is best to use SQL to handle most operations that need to go through multiple records.

Furthermore, the user interface of Access makes it easy to associate a control element with a column of a table or query. As a result, there is little need to manipulate columns of a row using custom code.

That said, many other applications supported by VBA do not offer an SQL interface into databases for many different reasons. As such, these applications need to rely on VBA loops to perform operations to a collection of items.