Microsoft Office Tutorials and References
In Depth Information
Enabling VBA Code
Private Sub, or Public Sub and ends with End Sub, using one of the
following general structures:
Sub name ()
... code ...
End Sub
Private Sub name ()
... code ...
End Sub
Public Sub name ()
... code ...
End Sub
name is the name of the procedure, and ... code ... is any amount of VBA
code.
Text that appears to be written in plain English within a module represents
programmer comments — notes for other programmers. The computer
ignores the comments. Every comment starts with an apostrophe (’) and
appears in a green font — unless you’ve changed VBE’s default settings.
Function procedures
A function procedure is enclosed in Function...End Function
statements, as the following code shows:
Function name ()
<...code...>
End Function
Public Function name ()
<...code...>
End Function
Private Function name ()
<...code...>
End Function
Unlike a sub procedure, which simply performs some task, a function
procedure performs a task and returns a value. In fact, an Access function
procedure is no different from any of the built-in functions you use in Access
expressions, and you can use a custom function procedure wherever you
can use a built-in procedure.
A Public procedure is available to all modules in Access. A Private
procedure is available only to other procedures in the same module.
 
Search JabSto ::




Custom Search