Solved

Locked files

Posted on 1998-07-29
1
199 Views
Last Modified: 2010-05-03
Is there a way to detect if a file is locked (in use)
0
Comment
Question by:dgb
1 Comment
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1467194
Function CheckOpenFile(sFile as String) as Boolean

   Dim nFile As Integer

   nFile = FreeFile

   on error goto Error_Read

   Open sFile For Input Lock Read As #nFile
   Close #nFile

   CheckOpenFile = False

   Exit Function
Error_Read:
   if Err = 70 then
      msgbox "File already open"
   End If

   close #nFile
   
   CheckOpenFile = True

   Exit Function

End Sub
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question