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
512 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

856 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