Home Privacy Policy Feedback Link to us Site Map

Access: GetAttr Function


In Access, the GetAttr function returns an integer that represents the attributes of a file, folder, or directory.

The syntax for the GetAttr function is:

GetAttr ( path )

path is the path to a file, folder, or directory that you wish to retrieve the attributes for.

The GetAttr will return one or a combination of the following values:

VB Constant Value Explanation
vbNormal 0 Normal
vbReadOnly 1 Read-only
vbHidden 2 Hidden
vbSystem 4 System file
vbDirectory 16 Directory or folder
vbArchive 32 File has been changed since last backup
vbAlias 64 File name is an alias

The VB Constants can only be referenced in VBA code and can not be used in Access queries.


For example:

GetAttr ("C:\instructions.doc") would return 0
GetAttr ("H:\Documents\Supplies.xls") would return 1

VBA Code

The GetAttr function can be used in VBA code. For example:

Dim LResult As Integer

LResult = GetAttr ("C:\instructions.doc")

In this example, the variable called LResult would now contain the integer representation of the attributes of the instructions.doc file.


SQL/Queries

You can also use the GetAttr function in a query.