MS Access Environ() Function
The Environ()
function in MS Access retrieves the value of an environment variable from the operating system. Environment variables are settings that affect how programs run on your computer.
Environ(): Definition and Usage
This function is primarily used in VBA (Visual Basic for Applications) code to access system-level information. You can retrieve the value of a variable either by its numerical index in the environment variable table or by providing its name as a string. The returned value is always a string.
Syntax
Syntax
Environ(number)
--or--
Environ(string)
Parameter Values
Parameter | Description |
---|---|
number |
The numerical index of the environment variable in the system's environment variable table. This is required when using numerical lookup. |
string |
The name of the environment variable (e.g., "PATH", "TEMP"). This is required when using string lookup. |
Example
Retrieving an Environment Variable by Index
This example retrieves the value of the first environment variable using its index (1). Note that the index and the returned value are both highly system-specific.
Syntax
SELECT Environ(1);
Output
(The value of the first environment variable on your system. Example: C:\Windows\system32)