11.4. When Not to Use VBA

There are times when you will attempt to solve a problem with VBA, only to find out that VBA is not the answer. The following example is such a case. Over time, you will learn to identify what can be solved with code, with a query or multiple queries, and also via the use of controls on a report.

When developing a report, there are things that you can do that don't require programming. Instead, with a properly placed control, or with the use of a grouping section, the desired functionality can be achieved. In this example, an index letter can be added to the start of each Alphabetical value in the report. This can be helpful for easy recognition of data by the user. Figure 11-11 demonstrates the desired effect.

Figure 11.11. Figure 11-11

In this report, each product is listed alphabetically. Where one letter ends, and the next begins, the starting letter is printed to assist the reader with locating their desired value. This functionality could be programmed in the report writer, but is easily implemented with just a text box control and a group.

Figure 11-12 displays the report called Alphabetical List of Products, which comes with the Northwind database example.

Figure 11.12. Figure 11-12

In Figure 11-12, notice that there is a report section called ...

Get Access 2003 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.