?
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
Medium Priority
?
529 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 1200 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 800 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Introduction to Processes
Suggested Courses

800 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