From the January 2016 Issue of Prestwood eMag
 
Access Language Basics:
Access VBA Comments (' or REM)
 
Posted 11/14/2008 on 11/14/2008 and updated 1/29/2009
Access Code Snippet:

KB101499

Languages Focus: Comments

Commenting code generally has three purposes: to document your code, for psuedo coding prior to coding, and to embed compiler directives. Most languages support both a single line comment and a multiple line comment. Some languages also use comments to give instructions to the compiler or interpreter.

Access VBA Comments

Commenting Code
Access VBA, like all the VB-based languages, uses a single quote (') or the original class-style basic "REM" (most developers just use a quote). Access VBA does NOT have a multiple line comment.

Directives - #

Directives are sometimes called compiler or preprocessor directives. A # is used for directives within Access VBA code. Access VBA offers only an #If..then/#ElseIf/#Else directive.

Syntax Example:
'Single line comment.

REM Old school single line comment.

#If MyDirective Then
'...some code.
#End If

Multi-Line Comment Code Trick

You can simulate a multi-line comment with code which is useful especially if you wish to comment out a block of code.

For example:

If False Then
 '...code here skipped.
End If

Using Directives

Here is a simple example of using VB Classic's directive (change True to False to switch it).

#Const MyDirective = True

#If MyDirective Then
      MsgBox ("Yes")
#Else
      MsgBox ("No")
#End If

Comments

1 Comments.
Share a thought or comment...
Comment 1 of 1

An access vba comments, the more objectives I have ever seen and sharing the great thoughts as well. I am getting here top essay writing service the more educational tips and wonderful british assignments.

Posted 3/25/2020
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile
www.prestwood.com For service: 916-726-5675
or support@prestwood.com
Copyright (C) Prestwood IT Solutions.
All Rights Reserved.
Printed 4/9/2020