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
526 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 85

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

728 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