Capturing Database Properties

  • Thread starter Thread starter ACG via AccessMonster.com
  • Start date Start date
A

ACG via AccessMonster.com

My problem seems quite simple!!! I am using Access 97 and what I am trying
to do is determin if a database properties are set to ReadOnly. i.e. What I
want to do is a simple check when a datbase is opened and if the properties
are Read Only display a message and quit.

At the moment, to get round the problem ,I have set up a temp table and try
to write to to it and if this errors because it is read only display the
message etc - but I think there must be an easier way.

Thanks in advance and any assistance would be greatly received.
 
Access already gives you a warning message when you open a read-only
mdb file.

Do you want to replace that message, or add your own one afterwards?

TC
 
Either really, but proberbly just add my own after the Access one. The
main thing is to give the user the warning and then quit the database.
 
I recommend that you review the message that Access already displays in
this case. It might or might not make sense to add your own message,
depending on the wording of the Access one. There's no way to suppress
the Access one, afaik.

Apart from the message, your next need is to quit the database (when it
is read-only). I /should/ know a simple, clean way of testing that, but
I can't think of it off the top of my head (and I don't have Access
here to check).

So, why not stick with your current method of trying to update a field
in a record? If you've already coded that, all you'd need is an On
Error statement to detect the right error, & quit the db.

Something like:

on error resume next
<try to update a field in a record>
select case err.number
case 0
' it worked.
case 9999
' oops, db is read only.
msgbox "no way jose!"
application.quit
case else
' some other, unexpected error.
msgbox "error " & err.number & _
": " & err.description
' quit, end, whatever ...
end select
on error 0

You'd need to replace '9999' with whatever error number you get in your
case.

HTH,
TC
 
Thanks for the help, and I like your code - it's certainly neater than mine.
 
Back
Top