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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

This is about my first experience with programming Arduino.
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
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 …

773 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