VBA Code To Determine Read Only Status

G

Guest

Greetins,
I posted this question on the new user page a couple days ago, but got no
response so I thought I'd try here.
I'd like to set the visible property to false on some forms if the database
is opened in a read-only mode (due to the security settings of the folder in
which it's placed).
I also need to adjust the code for the "On Open" event (I set it up to go to
a new record if none exists for that date).
In Excel, I've been able to use "ActiveWorkbook.ReadOnly" to adjust features
based on the user's permissions. Ideally I'd like to find something similar.
But if not, what can I do to work around the "Read Only" problems?
Any Help Will Be Appreciated.
Peace.
E.Q.
 
S

Stefan Hoffmann

hi,

E.Q. said:
I also need to adjust the code for the "On Open" event (I set it up to go to
a new record if none exists for that date).
In Excel, I've been able to use "ActiveWorkbook.ReadOnly" to adjust features
based on the user's permissions. Ideally I'd like to find something similar.
But if not, what can I do to work around the "Read Only" problems?
On form level you can use the properties AllowAdditions, AllowDeletions
and AllowEdits. On control level you can use Locked.


mfG
--> stefan <--
 
G

Guest

Thanks for the info, but the problem I'm having is how to tell if things are
read-only. I've been able to insert code via Error handling. But I would
prefer to deal with the problem directly... What if an error is generated
that's not due to the read-only nature of the database? My error handling
would be incorrect.
Also, even on opening the database I get a message saying that the database
is read-only and that no changes will be saved to data or objectss. I'd
prefer for the "Read-Only" crowd to not get that message.
Would this need to go out even futher and do something like an API call
(which I've never coded)? Or is there some what to tell if some Access object
is read-only via properties?
Peace.
E.Q.
 
S

Stefan Hoffmann

hi,

E.Q. said:
Thanks for the info, but the problem I'm having is how to tell if things are
read-only.
Ah, i didn't get this point. Only thing i knew:

Use an simple INSERT if it fails your database is readonly.


mfG
--> stefan <--
 
J

John Nurick

On approach would be to try and create a file in the folder in question:

Dim lngFN as Long
Dim lngErrNum As Long

lngFN = FreeFile()
On Error Resume Next
Open "D:\Folder\$$$__$$$.$$$" For Output As #lngFN
lngErrNum = Err.Number
On Error Goto 0
If lngErrNum <> 0 Then
'can't write to folder
Else
Close #lngFN
'continue
...
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top