Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Test if a particular database is open already? (Office 2000 Sr1a)

    I am using the OpenCurrentDatabase method via Automation to open a particular .mdb file but this sometimes gives problems if the database has been already opened (by a user, not programmatically).
    Is there some test in VBA to see if the file is open?
    Sort of like "IsLoaded" but for the entire database?
    Thanks!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Test if a particular database is open already? (Office 2000 Sr1a)

    One idea is to put

    On Error Resume Next

    before the OpenCurrentDatabase, and check the Err object after it:

    If Err <> 0 Then
    ' Something went wrong
    Else
    ' Database opened OK
    End If

    Another idea is to check for the existence of the corresponding .ldb file using the Dir of FileExists function. But this is not completely reliable - in some circumstances the .ldb file is not deleted properly.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Test if a particular database is open already? (Office 2000 Sr1a)

    It's a good idea but I don't seem to be able to get
    On Error Resume Next to work in my case because
    in fact my script is really a VBScript running under the Window's Scripting Host object. I'm using this because I'm running certain Automation actions on a timer (every five minutes) rather than in reponse to an event within another Office programme. I might try the ldb method though, as you say, it is not always reliable.
    And I need it to be reliable!
    Do you think there is something that would work in VbScript?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Test if a particular database is open already? (Office 2000 Sr1a)

    Sorry, my knowledge of VBScript is very limited. Anyone else?

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Test if a particular database is open already? (Office 2000 Sr1a)

    In article Check Who Logged into Database with Jet UserRoster in Access 2000 (Q198755) there is a function to see who is logged in in a database. Maybe you can use this. But like Hans I have no experience with VbScript.
    Francois

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Test if a particular database is open already? (Office 2000 Sr1a)

    When you say that checking the existance of the .ldb is not reliable, I have found it to be very reliable, the only time it seems to be left hanging around is if someone bombs out of the database.
    I have not noticed yet that an .ldb has been left after normal termination (except after Access 2 in the good ol' days) from the database.
    Pat

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Test if a particular database is open already? (Office 2000 Sr1a)

    Pat,

    You write
    <hr>the only time it seems to be left hanging around is if someone bombs out of the database<hr>
    That is my experience too, but unfortunately this happens from time to time on our network - sometimes caused by network problems, but also by impatient users wanting to leave the office in a hurry and just turning off the power to their computer, despite dire warnings [img]/forums/images/smilies/sad.gif[/img]

    Regards,
    Hans

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Test if a particular database is open already? (Office 2000 Sr1a)

    Sorry, this is a VERY tardy reply Fran

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •