D
Dick Sutton
I have a situation on a small office LAN where the dbms needs to be backed
up prior to the Office Manager leaving for the day. Since the users of the
data base may or may not have the dbms in use, I thought that I would check
the 'InUseCount' of one of the dbms files to see if it was in use. I know
that if this file is open, then the database is in use.
However, no matter when or how I run this code, the answer is always the
same: <null>. What am I overlooking? What am I doing wrong? See sample
code below.
Thanks in advance...
Dick
--------------------------------------------------------------------------------
Option Explicit
Dim oWMI, oFile, strFilePath
strFilePath = "C:\\MED\\mwtrn.adt"
Set oWMI = GetObject("winmgmts:\\.\root\cimv2")
Set oFile = oWMI.Get("CIM_DataFile.Name=""" & strFilePath & """")
If oFile.InUseCount > 0 Then
MsgBox "Med DBMS in use!"
Else
MsgBox "Good to go!"
End If
--------------------------------------------------------------------------------
up prior to the Office Manager leaving for the day. Since the users of the
data base may or may not have the dbms in use, I thought that I would check
the 'InUseCount' of one of the dbms files to see if it was in use. I know
that if this file is open, then the database is in use.
However, no matter when or how I run this code, the answer is always the
same: <null>. What am I overlooking? What am I doing wrong? See sample
code below.
Thanks in advance...
Dick
--------------------------------------------------------------------------------
Option Explicit
Dim oWMI, oFile, strFilePath
strFilePath = "C:\\MED\\mwtrn.adt"
Set oWMI = GetObject("winmgmts:\\.\root\cimv2")
Set oFile = oWMI.Get("CIM_DataFile.Name=""" & strFilePath & """")
If oFile.InUseCount > 0 Then
MsgBox "Med DBMS in use!"
Else
MsgBox "Good to go!"
End If
--------------------------------------------------------------------------------