O'Reilly logo

Beginning Access™ 2007 VBA by Denise Gosnell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.6. Documenting Your Code

It is a good idea to document your code very well so that you and others will be able to understand the purpose of each procedure and why it was written in a certain way. You can document your code in several ways. The ideal way to document your code is to use a general comment section at the beginning of each procedure and to use in-line comments to describe each segment of code. Here is an example of such a general comment section.

'*****************************************************************
'*
'* Procedure Name: TestProcedure
'*
'* Purpose: The purpose of this procedure is to illustrate why
'* documenting your code is so important.
'*
'* Parameters: None.
'*
'* Date Created: September 4, 2006
'* By:  Denise M. Gosnell
'*
'* Modification Log:
'* Date              Explanation of Modification       Modified By
'* ------------      ----------------------------------  ------------------------
'*
'******************************************************************

The preceding documentation style may be overkill if the procedure itself is only a few lines of code. Some type of general comment section should be used with all procedures, even if it is not as detailed as the one in the preceding code.

You have seen in-line comments in all the code examples throughout this chapter. Here is another example:

'display a message to the user
Msgbox "Demonstration of In-Line commenting"

It is always better to write too many comments than too few. As you gain more experience writing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required