ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Access DBs from Excel (https://www.excelbanter.com/excel-programming/306800-re-using-access-dbs-excel.html)

sebastienm

Using Access DBs from Excel
 
Hi,
Are you trying to query the database or do something else?

If the first case:
You can pull up data directly from Excel using the External Data featu
menu Data Get (or Import) External Data New Database Query. There choose
MS Access and follow the dialogs.
In vba, it is similar to buikding a QueryTable object. (do the step above
with the macro recorder On, then check at the automated code).

I hope this helps,
Regards,
Sébastien

"Mister T" wrote:

In an Excel routine, I access an Access database with a GetObject. But before
I do that, is there a way to find out if an instance of that particular DB
has already been launched? Thank you.


Mister T

Using Access DBs from Excel
 
Hi,

My problem is not about manipulating the Access object from my Excel VBA
code. Rather, what I want is not to do these manipulations at all in the
first place in case the Access DB is already open. So what I want to do is
detect whether or not the DB has already been instanced.

"sebastienm" wrote:

Hi,
Are you trying to query the database or do something else?

If the first case:
You can pull up data directly from Excel using the External Data featu
menu Data Get (or Import) External Data New Database Query. There choose
MS Access and follow the dialogs.
In vba, it is similar to buikding a QueryTable object. (do the step above
with the macro recorder On, then check at the automated code).

I hope this helps,
Regards,
Sébastien

"Mister T" wrote:

In an Excel routine, I access an Access database with a GetObject. But before
I do that, is there a way to find out if an instance of that particular DB
has already been launched? Thank you.


sebastienm

Using Access DBs from Excel
 
Is it a db on a network drive or on your computer only? for shared or
exclusive access?

I don't know much about it, but i remember being in the case, years ago, of
an MS Access db sitting on a network drive in shared mode, and everytime
someone would use it, the db was automatically keeping track of the user by
adding his network name into a 'lock' (? can't remember exactly the name)
file saved in the same directory.
I was using that file to determine connected user and ask them to un-connect
so that we could maintain/modify the db.

Sorry i can't help more,
Sébastien

"Mister T" wrote:

Hi,

My problem is not about manipulating the Access object from my Excel VBA
code. Rather, what I want is not to do these manipulations at all in the
first place in case the Access DB is already open. So what I want to do is
detect whether or not the DB has already been instanced.

"sebastienm" wrote:

Hi,
Are you trying to query the database or do something else?

If the first case:
You can pull up data directly from Excel using the External Data featu
menu Data Get (or Import) External Data New Database Query. There choose
MS Access and follow the dialogs.
In vba, it is similar to buikding a QueryTable object. (do the step above
with the macro recorder On, then check at the automated code).

I hope this helps,
Regards,
Sébastien

"Mister T" wrote:

In an Excel routine, I access an Access database with a GetObject. But before
I do that, is there a way to find out if an instance of that particular DB
has already been launched? Thank you.


Tom Ogilvy

Using Access DBs from Excel
 

http://support.microsoft.com?kbid=138621
XL: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=291295
XL2002: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=213383
XL2000: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=184982
WD97: VBA Function to Check If File or Document Is Open

--
Regards,
Tom Ogilvy


"Mister T" wrote in message
...
Hi,

My problem is not about manipulating the Access object from my Excel VBA
code. Rather, what I want is not to do these manipulations at all in the
first place in case the Access DB is already open. So what I want to do is
detect whether or not the DB has already been instanced.

"sebastienm" wrote:

Hi,
Are you trying to query the database or do something else?

If the first case:
You can pull up data directly from Excel using the External Data

featu
menu Data Get (or Import) External Data New Database Query. There

choose
MS Access and follow the dialogs.
In vba, it is similar to buikding a QueryTable object. (do the step

above
with the macro recorder On, then check at the automated code).

I hope this helps,
Regards,
Sébastien

"Mister T" wrote:

In an Excel routine, I access an Access database with a GetObject. But

before
I do that, is there a way to find out if an instance of that

particular DB
has already been launched? Thank you.




Tom Ogilvy

Using Access DBs from Excel
 
No. It uses the low level file io to open the file (in no application)
exclusively. If it can be opened exclusively, then it is not opened in
read/write mode by someone else. It has nothing to do with the file type or
the application where the function might be used.

Again, I know how to do what I want to the DB object after instancing it

with
the GetObject, but I need to know whether it's already in use before I

even
do my GetObject.


And I offered a solution to that problem.

--
Regards,
Tom Ogilvy


"Mister T" wrote in message
...
Thanks, but I don't know if the procedures mentioned below work in my

case.
It seems like they rely on using the Open statement to attempt opening an
Excel file within Excel and seeing if the file is locked. (Or the Word
example attempts to open a Word file within Word.)

What I'm trying to do is figure from Excel whether an Access file is

already
in use. So what makes my problem tricky is its inter-application nature.
Again, I know how to do what I want to the DB object after instancing it

with
the GetObject, but I need to know whether it's already in use before I

even
do my GetObject.

"Tom Ogilvy" wrote:


http://support.microsoft.com?kbid=138621
XL: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=291295
XL2002: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=213383
XL2000: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=184982
WD97: VBA Function to Check If File or Document Is Open

--
Regards,
Tom Ogilvy


"Mister T" wrote in message
...
Hi,

My problem is not about manipulating the Access object from my Excel

VBA
code. Rather, what I want is not to do these manipulations at all in

the
first place in case the Access DB is already open. So what I want to

do is
detect whether or not the DB has already been instanced.

"sebastienm" wrote:

Hi,
Are you trying to query the database or do something else?

If the first case:
You can pull up data directly from Excel using the External Data

featu
menu Data Get (or Import) External Data New Database Query. There

choose
MS Access and follow the dialogs.
In vba, it is similar to buikding a QueryTable object. (do the step

above
with the macro recorder On, then check at the automated code).

I hope this helps,
Regards,
Sébastien

"Mister T" wrote:

In an Excel routine, I access an Access database with a GetObject.

But
before
I do that, is there a way to find out if an instance of that

particular DB
has already been launched? Thank you.







Mister T

Using Access DBs from Excel
 
OK, great. Was not familiar with low level file io. Thank you.

"Tom Ogilvy" wrote:

No. It uses the low level file io to open the file (in no application)
exclusively. If it can be opened exclusively, then it is not opened in
read/write mode by someone else. It has nothing to do with the file type or
the application where the function might be used.

Again, I know how to do what I want to the DB object after instancing it

with
the GetObject, but I need to know whether it's already in use before I

even
do my GetObject.


And I offered a solution to that problem.

--
Regards,
Tom Ogilvy


"Mister T" wrote in message
...
Thanks, but I don't know if the procedures mentioned below work in my

case.
It seems like they rely on using the Open statement to attempt opening an
Excel file within Excel and seeing if the file is locked. (Or the Word
example attempts to open a Word file within Word.)

What I'm trying to do is figure from Excel whether an Access file is

already
in use. So what makes my problem tricky is its inter-application nature.
Again, I know how to do what I want to the DB object after instancing it

with
the GetObject, but I need to know whether it's already in use before I

even
do my GetObject.

"Tom Ogilvy" wrote:


http://support.microsoft.com?kbid=138621
XL: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=291295
XL2002: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=213383
XL2000: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=184982
WD97: VBA Function to Check If File or Document Is Open

--
Regards,
Tom Ogilvy


"Mister T" wrote in message
...
Hi,

My problem is not about manipulating the Access object from my Excel

VBA
code. Rather, what I want is not to do these manipulations at all in

the
first place in case the Access DB is already open. So what I want to

do is
detect whether or not the DB has already been instanced.

"sebastienm" wrote:

Hi,
Are you trying to query the database or do something else?

If the first case:
You can pull up data directly from Excel using the External Data
featu
menu Data Get (or Import) External Data New Database Query. There
choose
MS Access and follow the dialogs.
In vba, it is similar to buikding a QueryTable object. (do the step
above
with the macro recorder On, then check at the automated code).

I hope this helps,
Regards,
Sébastien

"Mister T" wrote:

In an Excel routine, I access an Access database with a GetObject.

But
before
I do that, is there a way to find out if an instance of that
particular DB
has already been launched? Thank you.








All times are GMT +1. The time now is 11:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com