Solved

Locked files

Posted on 1998-07-29
1
197 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now