A.D.Tejpal
adtp at touchtelindia.net
Wed Feb 16 10:39:23 CST 2005
Erwin,
You are most welcome! Yes, the status is returned correctly even from within the db.
Incidentally, if you attempt to open a db that is read only, Access comes up with a warning message as well.
An expanded version of the function is given below.
A.D.Tejpal
--------------
====================================
Function Fn_GetDbStatus(ByVal Fpt _
As String) As String
Dim fso As FileSystemObject, fe As File
Dim Dbs As Long, Sts As String
Sts = "Other" ' Default Value
Set fso = New FileSystemObject
Set fe = fso.GetFile(Fpt)
Dbs = fe.Attributes
Select Case Dbs
Case 1
Sts = "ReadOnly"
Case 2
Sts = "Hidden"
Case 32
Sts = "Archive"
Case 3
Sts = "ReadOnly + Hidden"
Case 33
Sts = "ReadOnly + Archive"
Case 34
Sts = "Archive + Hidden"
Case 35
Sts = "ReadOnly + Archive + Hidden"
End Select
Fn_GetDbStatus = Sts
Debug.Print Dbs
Set fso = Nothing
Set fe = Nothing
End Function
====================================
----- Original Message -----
From: Erwin Craps - IT Helps
To: Access Developers discussion and problem solving
Sent: Wednesday, February 16, 2005 16:59
Subject: RE: [AccessD] Knowing when DB is read-only
Thank you
Would I be able to get a correct filestatus from within the databasefile itself?
Erwin
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of A.D.Tejpal
Sent: Tuesday, February 15, 2005 7:39 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Knowing when DB is read-only
Erwin,
You should be able to get the status via file system object.
Suitable user defined function is given below. Reference to Microsoft
Scripting RunTime is needed.
Following expression will get the status for the current db.
Fn_GetDbStatus(CurrentProject.FullName)
With best wishes,
A.D.Tejpal
--------------
================================
Function Fn_GetDbStatus(ByVal Fpt _
As String) As String
Dim fso As FileSystemObject, fe As File
Dim Dbs As Long, Sts As String
Sts = "Other" ' Default Value
Set fso = New FileSystemObject
Set fe = fso.GetFile(Fpt)
Dbs = fe.Attributes
Select Case Dbs
Case 1
Sts = "ReadOnly"
Case 2
Sts = "Hidden"
Case 32
Sts = "Archive"
End Select
Fn_GetDbStatus = Sts
Set fso = Nothing
Set fe = Nothing
End Function
================================
----- Original Message -----
From: Erwin Craps - IT Helps
To: Access Developers discussion and problem solving
Sent: Tuesday, February 15, 2005 15:59
Subject: [AccessD] Knowing when DB is read-only
Dear group
I have a backend MDB database that is about 677MB in size and growing....
For reasons of fast recovery this file is not only backuped on tape several times a day, but also copied several times a day to my
notebook
computer (using briefcase but I don't use syncing at datalevel, just
file level).
Because copying this file takes about a minute or so, it seems that
the
database get's in a read-only state.
I noticed this because on my server two applications run every 2,5
minutes dooing some stuff on it, but during the filecopy I get "No
updateable query" errrors.
So the question is, how can I get the state of the database during
opening so I can leave straightaway the application on the server when
it notices that the backend is read-only or whatever state while
copying
the file to my notebook???
Greetz
Erwin Craps
Zaakvoerder