Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it read-only? 1

Status
Not open for further replies.

nagyf

Programmer
May 9, 2001
74
HU
How can I check in simplest way whether the current database file is read-only because the file itself is such or the it was opened by so from the command line?
[tt]
Ferenc Nagy
|\ /~ ~~|~~~ nagyf@alpha0.iki.kfki.hu Fax: (36-1)-392-2529 New!
| \ | | Institute of Isotope and Surface Chemistry
| \ | -+- 1525 Bp. POB 77. Tel. :(36-1)-392-2550
| \| | `-' ' `-' "The goal of the life is the struggle itself"
[/tt]
 
Code:
Function ReadOnlyDB() As Boolean

    Dim db As Database
    Set db = CurrentDb

    ReadOnlyDB = Not db.Updatable

End Function
VBSlammer
redinvader3walking.gif
 
Thank you, VBSlammer.

One more related question:

How can I check that the database or a folder is on a read-only device, like a CD? [tt]
Ferenc Nagy
|\ /~ ~~|~~~ nagyf@alpha0.iki.kfki.hu Fax: (36-1)-392-2529 New!
| \ | | Institute of Isotope and Surface Chemistry
| \ | -+- 1525 Bp. POB 77. Tel. :(36-1)-392-2550
| \| | `-' ' `-' "The goal of the life is the struggle itself"
[/tt]
 
Here is a simplistic method to check a file using its full path as an argument:

Code:
Function IsFileReadOnly(ByVal strFullPath As String) As Boolean

  Dim strFilename As String
  strFilename = Dir(strFullPath)
  
  If Len(strFilename) > 0 Then
    If GetAttr(strFullPath) And vbReadOnly Then
      IsFileReadOnly = True
    End If
  End If
  
End Function
VBSlammer
redinvader3walking.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top