Kenneth Courville wrote:
Hello, I'm looking for assistance with the Access object model. I know
this is VB, but I'm building an Office Add-using C# directed at Access
2002. I'm literate in VB, so you can reply in VB... I think my problem
mainly lies in knowing the quirks of the Access object model.
Basically, I'm looking for a method of determining if an Access database
is open yet. AND I'm looking for a method that doesn't not require
checking for an exception. It seems that even handled exceptions will
cause the add-in to not close properly.... eating up memory.
Currently, I have a timer that starts upon opening Access. Every 1/2
second, the timer_elasped event checks to see if a database is open.
So far, I found that I can check the property Application.Forms.Count >
0, which doesn't throw an exception if a database isn't open yet, but
still seems to cause the MSACCESS process to not close entirely upon
exit. And I've isolated the code the the use of this property. If I
take it out, the MSACCESS closes fine.
Ultimately, the process I'm try to automate:
- User opens Access.
- Add-in launches and waits for a database to be loaded.
- Database is loaded.
- Add-in detects database is opened
- Add-in determines if the current database is an ADE or ADP file
(Access Project).
If anyone has other suggestions for accomplishing this, I would greatly
appreciate it.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I believe there is some confusion about terminology, which may be caused
by the various definitions of "Database." Database can refer to an ODBC
database (Paradox, dBase, MS SQL Server, Oracle, etc.), or to an Access
database (file extensions: .mdb, .mde). ADP/E files are front-ends
connected to databases (tables, queries, stored procedures, views,
functions).
There is some confusion in Microsoft's own terminology. There is a
method, OpenDatabase (DAO), that can open an .mdb/e file. These files
are considered database files, but, they do not necessarily have any
tables in them.
"Application.Forms.Count" only counts the number of open forms in an
application. It does not determine if a database is open. A form can
be open w/o a database (tables/queries) being open. Forms can be bound
to tables/queries or unbound (not linked to tables/queries).
So the question is, "What do you mean by 'database'?" This begs the
question "Why do you want to know if a 'database' is open? What will
that tell you?"
Perhaps you'd be better served by using the CurrentProject.Name
property. In Access 2000, and higher versions, this property will
return the name of the file, which will have the extension you are
looking for.
<NitPick>
An .ADE file is a "locked" .ADP file. They are both Access Project
files. Locked means the forms, reports & VBA code modules are not
viewable nor editable.
</NitPick>
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQH2kAIechKqOuFEgEQK6XACghanLn33eZisG1gssCqyyxx q/Gf4AoJkX
t/1ndKS3+SJJorG5nBut8lpe
=dnS9
-----END PGP SIGNATURE-----