By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,996 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,996 IT Pros & Developers. It's quick & easy.

How to tell if application object is used...

P: n/a
Hello,

How do I tell if a variable dim'd as an Access.Application has something in
it.

dim mApp as Access.Application

set mApp = new Access.Application
mApp.OpenCurrentDatabase mydb.mdb

That works fine, then I close it

mApp.Quit

I "Quit" instead of .CloseCurrentDatabase so the msaccess.exe closes

Now I want to test if mApp has a db open. (I know it doesn't at this point,
but I need this for later)

Because I've already used mApp, Is Nothing does not work. All other
properties I've tried give me a message of "The remote server machine does
not exist or is unavailable".

Is there a way to check?

Thanks.

Matthew Wells
MW****@FirstByte.net
Oct 28 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Matthew Wells wrote:
Now I want to test if mApp has a db open. (I know it doesn't at this point,
but I need this for later)
After you open another database again, use this:

mApp.CurrentDb.Name

If it has a name property *that's* the database it has open. If it errors
out, no database is open for that application object.

--
Message posted via http://www.accessmonster.com

Oct 29 '06 #2

P: n/a
I know it's a common practice, but I don't like to deliberately create an
error. I'm trying to find a definite property that tells me the state of
the object. Are there any?

"Granny Spitz via AccessMonster.com" <u26473@uwewrote in message
news:6876b6307c8b8@uwe...
Matthew Wells wrote:
Now I want to test if mApp has a db open. (I know it doesn't at this
point,
but I need this for later)

After you open another database again, use this:

mApp.CurrentDb.Name

If it has a name property *that's* the database it has open. If it errors
out, no database is open for that application object.

--
Message posted via http://www.accessmonster.com

Oct 29 '06 #3

P: n/a
Matthew Wells wrote:
I know it's a common practice, but I don't like to deliberately create an
error.
That's what error handling is for. As any experienced programmer will tell
you, sometimes deliberately creating an error so that execution jumps to the
error handler is the easiest way to accomplish some tasks.
I'm trying to find a definite property that tells me the state of
the object. Are there any?
My advice was to check if the CurrentDb had a name, because that's the best
way I know how to do what you asked for. If you think I'm deliberately
withholding information from you see for yourself in the Object Browser.

--
Message posted via http://www.accessmonster.com

Oct 29 '06 #4

P: n/a
Matthew Wells wrote:
I know it's a common practice, but I don't like to deliberately create an
error. I'm trying to find a definite property that tells me the state of
the object. Are there any?
Of course there are, but I am permitted to tell you only if Granny
gives her approval. I'm sorry.

Oct 29 '06 #5

P: n/a
Lyle Fairfield wrote:
Of course there are, but I am permitted to tell you only if Granny
gives her approval.
Lyle knows more about Access than I do. If he says something is so, it must
be. Please let the cat out of the bag, Lyle! You have my gratitude! (And a
plate of oatmeal cookies!)

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200610/1

Oct 29 '06 #6

P: n/a
I'm trying to find a definite property that tells me the state of
the object. Are there any?
I'd make myApp into a custom class, have a state property, set the
accessObject = nothing when you are not using it.

Keith

Oct 29 '06 #7

P: n/a

Granny Spitz via AccessMonster.com wrote:
Please let the cat out of the bag, Lyle! You have my gratitude! (And a
plate of oatmeal cookies!)
This cat hasn't a clue, Granny!

I could speculate that Access and databases have little or no direct
interaction. It's DAO that works with the db and Access simply gives us
an interface to interact with that DAO. So I supsect that open or
closed, something ot nothing, quit or unquit, Access applications do
not "have" databases. They may or may not create and expose an instance
of DAO that may "have" a database, but there is no intrinsic property
of an Access application that contains or references a db (No, not
CurrentDB which is simply a channel to a copy of the default db made by
DAO). Access is a bunch of screen procedures and connects to VBA and,
usually, DAO. It's an ActiveX/Com host.

Of course, once we quit the Access application it's a bit much to think
the pointer to it will still have properties. The variable is not the
application; it's simply a pointer to a pointer to a memory location
where there is a pointer to the application object.

.... blah blah blah

Oct 30 '06 #8

P: n/a
Lyle Fairfield wrote:
I could speculate that Access and databases have little or no direct
interaction. It's DAO that works with the db and Access simply gives us
an interface to interact with that DAO.
Thanks for that information, Lyle. At least Matthew has a course of action
despite the inadequacies of the interaction between the Access application
and DAO.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200610/1

Oct 30 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.