HomePrivacy PolicyFeedbackLink to usSite Map

MS Access: SetAttr Statement


In Access, the SetAttr statement allows you to set the attributes of a file.

The syntax for the SetAttr function is:

SetAttr path, attributes

path is the path to a file that you wish to set the attributes for.

attributes are the attributes that you'd like to attribute to the file. Attributes can be the following values:

VB Constant Value Explanation
vbNormal 0 Normal (default)
vbReadOnly 1 Read-only
vbHidden 2 Hidden
vbSystem 4 System file
vbArchive 32 File has been changed since last backup
vbAlias 64 File name is an alias (Macintosh only)

For example:

SetAttr "C:\instructions.doc", vbNormal would set the file to Normal
SetAttr "C:\instructions.doc", vbReadOnly + vbHidden would set the file to ReadOnly and Hidden

VBA Code

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

SetAttr "c:\Test\Doc1.doc", vbReadOnly + vbHidden

In this example, the file called Doc1.doc (found in the c:\Test\ directory) would now be set to a ReadOnly, Hidden file.