Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Access
3rdpartyusrgrp
access
activexcontrol
adp.sqlserver
commandbarsui
conversion
dataaccess.pages
developers.toolkitode
devtoolkits
externaldata
forms
formscoding
gettingstarted
internet
interopoledde
macros
modulescoding
modulesdaovba
modulesdaovba.ado
multiuser
odbcclientsvr
queries
replication
reports
security
setupconfig
tablesdbdesign
  
 
date: Tue, 22 Jul 2008 23:45:29 GMT,    group: microsoft.public.access.modulesdaovba        back       


Is there a way to tell if a certain Access application or instance is open?   
Hello all,
Is there a way of determining if a cerain Access app is open?

I have a number of Access apps I've written for an office and at any given
time any number of those app's could be open at the same time by various
users doing their daily work.
So now I'm building a generic front-end updater to update all of them based
on parameters sent to it (like 'ok updater, this users front-end x is out of
date so update it, that users front-end y is out of date so update it, new
version of front-end z is available so push to everybody - kinda like my own
Access SMS) but in doing this, my updater needs to know if user x has front-
end x open and if so, close it before running the update (on the users local
machine, not across a network).
Problem is I can't figure out if Access DB or Access instance x is open or
not.  I tried GetObject(,"Access.Application) .name, and I tried the DBEngine.
Workspaces collection but they only give me the first instance of Access
thats open whether I have one or a dozen Access app's open at once, and thats
where I ran out of ideas short of using Windows API calls to iterate through
open windows (didn't wanna do that cuz it seems unclean somehow).

So here I am asking the group, how do I find out which Access DB's or
instances (or whatever the correct terminology is) are open?

Thanks,
Kelly D.

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200807/1
date: Tue, 22 Jul 2008 23:45:29 GMT   author:   bkdraper via AccessMonster.com u7849@uwe

Re: Is there a way to tell if a certain Access application or instance is open?   
"bkdraper via AccessMonster.com" <u7849@uwe> wrote in message 
news:878cf3b81052d@uwe...
> Hello all,
> Is there a way of determining if a cerain Access app is open?
>
> I have a number of Access apps I've written for an office and at any given
> time any number of those app's could be open at the same time by various
> users doing their daily work.
> So now I'm building a generic front-end updater to update all of them 
> based
> on parameters sent to it (like 'ok updater, this users front-end x is out 
> of
> date so update it, that users front-end y is out of date so update it, new
> version of front-end z is available so push to everybody - kinda like my 
> own
> Access SMS) but in doing this, my updater needs to know if user x has 
> front-
> end x open and if so, close it before running the update (on the users 
> local
> machine, not across a network).
> Problem is I can't figure out if Access DB or Access instance x is open or
> not.  I tried GetObject(,"Access.Application) .name, and I tried the 
> DBEngine.
> Workspaces collection but they only give me the first instance of Access
> thats open whether I have one or a dozen Access app's open at once, and 
> thats
> where I ran out of ideas short of using Windows API calls to iterate 
> through
> open windows (didn't wanna do that cuz it seems unclean somehow).
>
> So here I am asking the group, how do I find out which Access DB's or
> instances (or whatever the correct terminology is) are open?
>
> Thanks,
> Kelly D.
>
> -- 
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200807/1
>

If \\machine_name\folder_name\access_file.ldb exists, then 
\\machine_name\folder_name\access_file.mdb is open. When the app closes, the 
ldb file is deleted.

HTH
date: Wed, 23 Jul 2008 01:13:28 +0100   author:   Stuart McCall

Re: Is there a way to tell if a certain Access application or instance is open?   
"Stuart McCall"  wrote in message 
news:g65t3h$3qu$1$8300dec7@news.demon.co.uk...
> "bkdraper via AccessMonster.com" <u7849@uwe> wrote in message 
> news:878cf3b81052d@uwe...
>> Hello all,
>> Is there a way of determining if a cerain Access app is open?
>>
>> I have a number of Access apps I've written for an office and at any 
>> given
>> time any number of those app's could be open at the same time by various
>> users doing their daily work.
>> So now I'm building a generic front-end updater to update all of them 
>> based
>> on parameters sent to it (like 'ok updater, this users front-end x is out 
>> of
>> date so update it, that users front-end y is out of date so update it, 
>> new
>> version of front-end z is available so push to everybody - kinda like my 
>> own
>> Access SMS) but in doing this, my updater needs to know if user x has 
>> front-
>> end x open and if so, close it before running the update (on the users 
>> local
>> machine, not across a network).
>> Problem is I can't figure out if Access DB or Access instance x is open 
>> or
>> not.  I tried GetObject(,"Access.Application) .name, and I tried the 
>> DBEngine.
>> Workspaces collection but they only give me the first instance of Access
>> thats open whether I have one or a dozen Access app's open at once, and 
>> thats
>> where I ran out of ideas short of using Windows API calls to iterate 
>> through
>> open windows (didn't wanna do that cuz it seems unclean somehow).
>>
>> So here I am asking the group, how do I find out which Access DB's or
>> instances (or whatever the correct terminology is) are open?
>>
>> Thanks,
>> Kelly D.
>>
>> -- 
>> Message posted via AccessMonster.com
>> http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200807/1
>>
>
> If \\machine_name\folder_name\access_file.ldb exists, then 
> \\machine_name\folder_name\access_file.mdb is open. When the app closes, 
> the ldb file is deleted.
>
> HTH

Errata: That last sentence should have read:

When all instances of the app are closed, the ldb file is deleted
date: Wed, 23 Jul 2008 01:44:54 +0100   author:   Stuart McCall

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
date: Wed, 23 Jul 2008 20:04:13 GMT   author:   bkdraper via AccessMonster.com u7849@uwe

Re: Is there a way to tell if a certain Access application or instance is open?   
Errata: I'm an idiot.  your name is Stuart, not Steve.  I humbly appologize.

-- 
Kelly D

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200807/1
date: Wed, 23 Jul 2008 20:06:54 GMT   author:   bkdraper via AccessMonster.com u7849@uwe

Re: Is there a way to tell if a certain Access application or instance is open?   
"bkdraper via AccessMonster.com" <u7849@uwe> wrote in message 
news:879797df39b06@uwe...
>
> 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

I would stick a DoEvents in that loop, otherwise your app may 'freeze' for a 
bit.

Better still, forget the loop altogether and use the Sleep api function. 
Paste this into the declarations section of your module:

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As 
Long)

Then replace the loop with (say) Sleep 1000. This function only suspends the 
thread it's launched in, so other threads will still run normally.

PS the name substitution has happened before and no doubt will again. I'm 
bullet-proof so it's no problem  :-)
date: Wed, 23 Jul 2008 22:08:05 +0100   author:   Stuart McCall

Re: Is there a way to tell if a certain Access application or instance is open?   
Good call, Sleep is even better.  Thanks again.

-- 
Kelly D

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200807/1
date: Wed, 23 Jul 2008 22:03:48 GMT   author:   bkdraper via AccessMonster.com u7849@uwe

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us