PDA

View Full Version : Solved: How to access database file properties?



eed
12-23-2004, 08:02 AM
Hi, all,

Is there a way (I don't know, using API or something?) to determine whether the current database file is marked as read-only? I'm having issues with a customer trying to run a tool off CD (which of course means it's read-only).

When any one specific operation fails, I can react with a specific error-handling message. But for concision's sake, I would like to just put something in the Form_Load event of my main switchboard to say, "If this database file is read-only, give the user this reminder message that the file will not run all its functions properly, and that the user should save the file to an updatable location and change its read-only property."

So... what would be the syntax to make my code ask Windows whether the file's Read-Only property is set? Thanks in advance for any thoughts!!

~ eed

GP George
12-23-2004, 11:25 AM
The API calls to identify connected drives and their attributes is here: http://www.mvps.org/access/api/api0003.htm

You can combine the fDriveType function form the above code with a call to the CurDir function to identify where the database is currently running, and, if it is the CD ROM, display your message.

HTH

George

zilpher
12-26-2004, 08:39 AM
This will tell you if a drive is a CD ROM:

Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

Sub foo()

'valid returns are:
'2 Removeable disk (such as floppy drive)
'3 Fixed drive
'4 Remote or Network drive
'5 CD Rom
'6 RAM Disk
' all other returns (usually 1) drive type unknown

If GetDriveType(Left(CurrentDb.Name, 3)) = 5 Then MsgBox "CDROM!"
End Sub


How about the Updateable property of the currentdb object?

Debug.Print CurrentDb.Updatable

HTH

eed
12-27-2004, 06:38 AM
Yes, the CurrentDb.Updatable property captured what I needed to know. That was simple, wonder why I didn't think of it. The DriveType approach would probably allow me to accomplish the same thing, but the Updatable property is more straightforward (and it will flag a read-only file regardless of drive).

Thanks so much for the help, zilpher and GP George!!! :kiss