Adding Comments to Code

You add comments, which have been color-coded in versions of Access since Access 97, to modules by using an apostrophe ('). You can place the apostrophe at the beginning of the line of code or anywhere within it. The compiler considers anything following the apostrophe a comment. Figure 23.9 shows code that contains comments.

Figure 23.9. Code containing comments that clarify what the subroutine is doing.



Many people ask if it is possible to comment several lines of code at once. Although not easily discoverable, the process is quite simple. Within the VBE, you right-click any toolbar or menu bar and display the Edit toolbar. You select the text you want to comment, and then you click the Comment Block tool on the Edit toolbar. To uncomment the block of code, you select the text you want to uncomment and then you click the Uncomment Block tool.

    Part III: Creating Your Own Database and Objects
    Part V: Advanced Topics