PC Review


Reply
Thread Tools Rate Thread

How can I check if an Access database is open?

 
 
Mike L
Guest
Posts: n/a
 
      12th Oct 2008
I need to determine from one Access database whether another Access database
is open. How can I do this?


 
Reply With Quote
 
 
 
 
Stuart McCall
Guest
Posts: n/a
 
      12th Oct 2008
"Mike L" <(E-Mail Removed)> wrote in message
news:48f17a9f$0$7343$(E-Mail Removed)...
>I need to determine from one Access database whether another Access
>database is open. How can I do this?


Look for the presence of a xxx.ldb file in the same folder as the database
file, where xxx is the same name as the database. If .ldb file is present,
the database is open. Use the Dir function.



 
Reply With Quote
 
Mike L
Guest
Posts: n/a
 
      12th Oct 2008
Thanks, Stuart. But if the target .mdb is terminated abnormally, the .ldb
may still exist. Is there another way, perhaps using the windows api?

I thought of having the target mdb write the system date/time to an internal
table every minute; link to this table and check if no update has occurred
within the past minute, which would indicate that the target mdb is not
executing. Hoping there is an easier way.

"Stuart McCall" <(E-Mail Removed)> wrote in message
news:eHsO$(E-Mail Removed)...
> "Mike L" <(E-Mail Removed)> wrote in message
> news:48f17a9f$0$7343$(E-Mail Removed)...
>>I need to determine from one Access database whether another Access
>>database is open. How can I do this?

>
> Look for the presence of a xxx.ldb file in the same folder as the database
> file, where xxx is the same name as the database. If .ldb file is present,
> the database is open. Use the Dir function.
>
>
>



 
Reply With Quote
 
Stuart McCall
Guest
Posts: n/a
 
      12th Oct 2008
"Mike L" <(E-Mail Removed)> wrote in message
news:48f18cd2$0$7345$(E-Mail Removed)...
> Thanks, Stuart. But if the target .mdb is terminated abnormally, the .ldb
> may still exist. Is there another way, perhaps using the windows api?
>
> I thought of having the target mdb write the system date/time to an
> internal table every minute; link to this table and check if no update has
> occurred within the past minute, which would indicate that the target mdb
> is not executing. Hoping there is an easier way.

<snip>

Ok. Try this:

Public Function dbOpen(dbFile As String) As Boolean
Dim fh As Integer

fh = FreeFile
On Error Resume Next
Open dbFile For Binary Access Read Write Shared As fh
dbOpen = (Err.Number > 0)
Close fh
End Function

If dbFile is open, it will be locked by the OS and the Open command will
fail.


 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      12th Oct 2008
Mike L wrote:

>I need to determine from one Access database whether another Access database
>is open. How can I do this?



I think you can just try to use OpenDatabase with the
Exclusive Option.

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
Mike L
Guest
Posts: n/a
 
      12th Oct 2008
I like your suggestion and will give it a try. Thanks very much.

"Stuart McCall" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Mike L" <(E-Mail Removed)> wrote in message
> news:48f18cd2$0$7345$(E-Mail Removed)...
>> Thanks, Stuart. But if the target .mdb is terminated abnormally, the
>> .ldb may still exist. Is there another way, perhaps using the windows
>> api?
>>
>> I thought of having the target mdb write the system date/time to an
>> internal table every minute; link to this table and check if no update
>> has occurred within the past minute, which would indicate that the target
>> mdb is not executing. Hoping there is an easier way.

> <snip>
>
> Ok. Try this:
>
> Public Function dbOpen(dbFile As String) As Boolean
> Dim fh As Integer
>
> fh = FreeFile
> On Error Resume Next
> Open dbFile For Binary Access Read Write Shared As fh
> dbOpen = (Err.Number > 0)
> Close fh
> End Function
>
> If dbFile is open, it will be locked by the OS and the Open command will
> fail.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to open an Access database object - Access Database Becomes Inaccessible Suzane Brandy Microsoft Access 2 21st Apr 2010 07:33 AM
How to Check Database's Read-Only Attribute After Database is Open =?Utf-8?B?UGFwdXR4aQ==?= Microsoft Access 1 18th Sep 2007 12:45 AM
Access 2007 check file format of open database =?Utf-8?B?U2FsbHkgR3JlZW4=?= Microsoft Access 8 11th Sep 2007 07:04 AM
Unable to open the Database in PLD Check Moin Microsoft Excel Crashes 0 9th Sep 2004 05:29 PM
How to check whether an access database is open programmically? Z. Marani Microsoft Access 1 30th Apr 2004 04:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:19 PM.