Option Private Statement

Description

Used at module level to indicate that an entire module is private.

Syntax

Option Private Module

Remarks

If used, the Option Private statement must appear in a module before any statements that declare variables or define constants.

The public parts (variables, objects, and user-defined types declared at module level) of modules declared private using the Option Private statement are still available within the project containing the module, but they are not available to other applications or projects.

Note Option Private is only useful for host applications that support simultaneous loading of multiple projects and permit references between the loaded projects. For example, Microsoft Excel version 5.0 permits loading of multiple projects, while Microsoft Visual Basic does not.

See Also

Option Base Statement, Option Compare Statement, Option Explicit Statement, Private Statement, Public Statement.

Specifics (Microsoft Access)

When you include the Option Private statement in a standard module in Microsoft Access, any public identifiers in the module are still available to all other procedures in the current database. However, they are not available to other databases.

Note If a standard module includes the Option Private statement, it will not be visible in the Object Browser from any other referencing Microsoft Access database.

You cannot have an Option Private statement in form modules or report modules because they are always private.

Example

The following example demonstrates the Option Private statement, which is used at the module level in a standard module to indicate that the entire module is private. If a module contains an Option Private Module statement, any public procedures can be called from other modules in the database, but not from another database.


Option Private Module        ' Indicates that module is private.