Solved

how to check when i open an access file whether the file is already open in another process

Posted on 2013-05-26
5
478 Views
Last Modified: 2013-05-28
hi

how can i check with code when i open an microsoft access file if this file is already opened by another process
0
Comment
Question by:bill201
  • 2
  • 2
5 Comments
 
LVL 27

Expert Comment

by:jjafferr
ID: 39198042
Hi

Whenever you open an mdb, an ldb is opened with it,
so if you can read the info in it, you can determine how many people are using your particular mdb.

Here is a link to the code:
http://support.microsoft.com/default.aspx?scid=kb;en-us;186304

jaffer
0
 

Author Comment

by:bill201
ID: 39198207
Sorry but it looks a little too complicated for me, and I could not run the code
0
 
LVL 27

Accepted Solution

by:
jjafferr earned 300 total points
ID: 39198939
place the following code On Click event of a button, and a message will popup telling you the number of users logged in

    Dim TextLine, ldb_file

    ldb_file = Application.CurrentDb.Name
    
    'check the extention
    If Right(ldb_file, 3) = "mdb" Then
        ldb_file = Replace(ldb_file, ".mdb", ".ldb")
    ElseIf Right(ldb_file, 5) = "accdb" Then
        ldb_file = Replace(ldb_file, ".accdb", ".laccdb")
    End If
    
    ' Open file.
    Open ldb_file For Input As #1
        Line Input #1, TextLine    ' Read line into variable.
    Close #1    ' Close file.
    
    MsgBox "there are " & Len(TextLine) / 62 & " user/s using " & Application.CurrentDb.Name

Open in new window


jaffer
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 200 total points
ID: 39200742
Note that it's possible for the lockfile to be created somewhere other than the folder hosting the database, so be sure that the folder hosting that database has read/write permissions. Some applications that use Access database don't require those permissions (like a .NET app that uses an Access db), and this can throw you for a loop if you're not careful.
0
 

Author Closing Comment

by:bill201
ID: 39200885
jjafferr thanks a lot for the code

LSMConsulting thank a lot the important tip
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

20 Experts available now in Live!

Get 1:1 Help Now