A
alex
Is File Open
Hello,
Using Access ’03…
I have code in my db that, when executed, looks to see if it (the
file) is already opened. If so, provide msgbox and close; if not,
open the file.
The code looks for the presence of the ldb. This works, but when the
db is improperly closed (due to a host of issues; network problems,
etc.) the ldb exists when the file is not actually opened.
I then wrote this code:
----------
On error goto ldb_Err
Dim ldbName As String
ldbName = "File.ldb"
'check to see if ldb exists on drive
If Len(Dir("Q:\" & ldbName)) > 0 Then 'file exists
Kill ("Q:\" & ldbName) 'delete the ldb
Exit Function
Else
'file is not open continue to next function
End If
Exit Function
ldb_Err:
If Err.Number = 70 Then 'could not delete the ldb because it's
truly open
MsgBox "File is already open!"
DoCmd.Quit acQuitSaveNone
Else
MsgBox "Enter Msg here" 'some other error occurred
DoCmd.Quit acQuitSaveNone
End If
----------
This code also works, but I get a little nervous killing files. Is
there another way to check to see if an mde is open, or is the code
above the best way to accomplish the task?
Thanks,
alex
Hello,
Using Access ’03…
I have code in my db that, when executed, looks to see if it (the
file) is already opened. If so, provide msgbox and close; if not,
open the file.
The code looks for the presence of the ldb. This works, but when the
db is improperly closed (due to a host of issues; network problems,
etc.) the ldb exists when the file is not actually opened.
I then wrote this code:
----------
On error goto ldb_Err
Dim ldbName As String
ldbName = "File.ldb"
'check to see if ldb exists on drive
If Len(Dir("Q:\" & ldbName)) > 0 Then 'file exists
Kill ("Q:\" & ldbName) 'delete the ldb
Exit Function
Else
'file is not open continue to next function
End If
Exit Function
ldb_Err:
If Err.Number = 70 Then 'could not delete the ldb because it's
truly open
MsgBox "File is already open!"
DoCmd.Quit acQuitSaveNone
Else
MsgBox "Enter Msg here" 'some other error occurred
DoCmd.Quit acQuitSaveNone
End If
----------
This code also works, but I get a little nervous killing files. Is
there another way to check to see if an mde is open, or is the code
above the best way to accomplish the task?
Thanks,
alex