How to change the files atribute by code ?

  • Thread starter Thread starter Javier G via AccessMonster.com
  • Start date Start date
J

Javier G via AccessMonster.com

Hi,
How to change te the file attributes by code ?
I need to change the Read-only check box attributes (properties) of a MDB
file but by code.

thnak you !
 
From Javier G via AccessMonster.com :
Hi,
How to change te the file attributes by code ?
I need to change the Read-only check box attributes (properties) of a MDB
file but by code.

thnak you !

Look at the (build in) SetAttr function.
 
Javier,

The code is something like:

SetAttr "path and filename here", vbReadOnly

or,

SetAttr "path and filename here", vbNormal

I take it you will be doing this on another (closed) .mdb file, not the
current one?

HTH,
Nikos
 
Thak you ! very helpful information.

where I can find all constants ????? ,
I tried in Microsoft but ,.........nothing found I did no found neither in
Access 2003 Help :-(((

I found some constants only but Not all them


strPath = CurrentProject.Path & "\"
strFile = "MiFile.mdb"

IntAtributeFile = GetAttr(strPath & strFile)

Select Case IntAtributeFile

Case 32
MsgBox "NORMAL file"

Case 33
MsgBox "READ ONLY file"

Case 34
MsgBox "HIDDEN file"

Case 35
MsgBox "READ + HIDDEN file"

Case 2080
MsgBox "COMPRESS file"

.....
.....
Case Else
MsgBox "Not supported"

End Select

I need All constants. it will be apreciate, thank you.
Javier
 
The constants are actually binary powers:

Value Description
0 Normal (vbNormal)
1 Read-only (vbReadOnly)
2 Hidden (vbHidden)
4 System (vbSystem)
16 Directory or folder (vbDirectory)
32 File has changed since last backup (vbArchive)

What you're showing as Normal in your list is actually a file that has its
Archive flag set (to indicate that the file has not been backed up yet).

A Read-only file that hasn't been backed up is vbReadOnly Or vbArchive, or
33.

A read-only, hidden, system file that hasn't been backed up is vbRead-only
Or vbHidden Or vbSystem Or vbArchive, or 38.

To determine whether a particular file is read-only, you'd And its
attributes with vbReadOnly. If the result is non-zero (or, more
specifically, if the result is equal to vbReadOnly), then the file is
read-only.

Now, the list above is the "official" list that comes from the documentation
(see, for instance,
http://msdn.microsoft.com/library/en-us/vbenlr98/html/vafctgetattr.asp but
it does seem incomplete.

For example, in NT and up, you can have compressed files. That attribute is
2048. You can also have encrypted files, which are designated with an
attribute of 8192. (a file can be either compressed or encrypted, not both).

There's a gap there: I would expect attributes of 64, 128, 256, 512, 1024
and 4096, but I don't see any definitions for those in any of the
documentation I've read.
 
OK !! Thanks Douglas for answering me , now everything is clear.
Regards
Javier
 
Back
Top