Re: Is there a way to tell if a certain Access application or instance is open?



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

.



Relevant Pages

  • RE: Next Number and Unused Registration Number
    ... If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?", ... "Steve Sanford" wrote: ... NoInd = GetNextNumber ... Dim r As DAO.Recordset ...
    (microsoft.public.access.forms)
  • RE: Error Trap not working
    ... "Steve C" wrote: ... Dim ColAAddress As String, ColAName As String, ColBRange as String ... 'Code here that names the range of cells in Col. B as ColBRange ...
    (microsoft.public.excel.programming)
  • Re: creating "map" based on field values
    ... Steve! ... Dim Rst As DAO.Recordset ... Dim intS As Integer ... but all the labels came out blue. ...
    (microsoft.public.access.reports)
  • Re: The following works ---
    ... Steve, I think you're doing it the hard way. ... Dim a module level variable ... In the change event for the code set the variable equal to the .Text ... >> textbox in the form header. ...
    (microsoft.public.access.gettingstarted)
  • RE: Problem with code (Loop without DO)
    ... "Steve Sanford" wrote: ... ** You didin't declare these variables: ... BTW, the variable "intTrans" should be declared as Boolean, not ... Dim db As DAO.Database ...
    (microsoft.public.access.modulesdaovba)