Re: Is there a way to tell if a certain Access application or instance is open?
- From: "bkdraper via AccessMonster.com" <u7849@uwe>
- Date: Wed, 23 Jul 2008 20:04:13 GMT
Very clever Steve.
I got so single-minded thinking of how to iterate through open instances of
Access that I forgot to step back and think if there was a functional work-
around.
if FileExists(.ldb) then GetObject(.mdb) : obj.Quit : Do until not FileExists
(.ldb) : move on.
Since I personally get annoyed when I find a thread of exactly what I'm
looking for only to discover that nobody posts a solution, just a comment
that says 'oh, i get it', So for any future readers of this thread, I shall
elaborate on my discovery based on Steves solution:
Instantiate a FileSystemObject, your project needs a reference to the
Microsoft Scripting Runtime.
Also Dim an Access object
Dim FS as New Scripting.FileSystemObject
Dim Acc as Access.Application
(yeah, i know it's better to declare then Set instead of New, but I'm too
lazy to type that much - otherwise I'd be writing in C instead of VB :) )
Use that FS object to see if a lock file exists for your app (thanks Steve)
and close it.
If FS.FileExists("C:\MyPath\MyAccesApp.LDB") then 'app is open so Set
your object
Set Acc = GetObject("C:\MyPath\MyAccessApp.MDB")
Acc.Quit
End if
It takes a minute for the LDB to delete so give it some time but Murphey's
law says something could mess up so you better give yourself an escape or
else you could end up in an infinite loop.
Do Until Not (FS.FileExists("C:\MyPath\MyAccesApp.LDB")) OR (C=10000)
C=C+1 'Even on a fast machine the LDB should be gone long before C
reaches 10000
Loop
Clean up after yourself cuz we're not sloppy coders here
Set Acc = Nothing
Set FS = Nothing
then finish doing what needs doing with your code.
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200807/1
.
- Follow-Ups:
- Re: Is there a way to tell if a certain Access application or instance is open?
- From: Stuart McCall
- Re: Is there a way to tell if a certain Access application or instance is open?
- From: bkdraper via AccessMonster.com
- Re: Is there a way to tell if a certain Access application or instance is open?
- References:
- Is there a way to tell if a certain Access application or instance is open?
- From: bkdraper via AccessMonster.com
- Re: Is there a way to tell if a certain Access application or instance is open?
- From: Stuart McCall
- Re: Is there a way to tell if a certain Access application or instance is open?
- From: Stuart McCall
- Is there a way to tell if a certain Access application or instance is open?
- Prev by Date: if then msgbox
- Next by Date: Re: Is there a way to tell if a certain Access application or instance is open?
- Previous by thread: Re: Is there a way to tell if a certain Access application or instance is open?
- Next by thread: Re: Is there a way to tell if a certain Access application or instance is open?
- Index(es):
Relevant Pages
|