473,418 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Determining if an Access Project is open

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.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
6 3612
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.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Don't know. However, it seems you want to close Access cleanly. I
suppose you have a form that is open with your timer interval. In the
OnClose or OnDeavtivate event of the form set your timer interval to 0.
Make sure the form closes correctly.

Nov 12 '05 #2
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-----

Nov 12 '05 #3
Actually, at this point, I'm not really concerned about forms... just
the Access application.

The add-in has a shutting down event that is fired when you close
Access. I'm using this to stop and destroy the timer properly.

Right now, the code that is causing the issue is the code that checks to
see if an Access database or project is loaded. If I take it out, the
MSACCESS process closes properly.

I wanted to avoid posting C# code under VB, but maybe it'll help...
Here is my timer_Elasped event... the problematic lines are marked with
arrows:

private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
string projectName = "";

// Get project name
// If no name exists yet, set project name to a blank value
try
{
--> if( applicationObject.Forms.Count > 0 )
--> {
--> projectName = applicationObject.CurrentProject.Name;
--> }
--> else
--> projectName = "";
}
catch( Exception ex )
{
System.Diagnostics.Debug.WriteLine( ex.StackTrace );
projectName = "";
}
catch
{
System.Diagnostics.Debug.WriteLine( "unknown exception" );
}
// If an Access Project is loaded, load the Access Manager Bar
if( projectName.ToUpper().EndsWith(COMPILED_PROJECT_EX TENSION) ||
projectName.ToUpper().EndsWith(PROJECT_EXTENSION) )
{
timer.Stop();
CreateCommandBar();
}

}

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4
Please review:
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).

By "database", I mean an Access "document": mdb, mde, ade, adp, etc.

Basically, if the user opens Access first, instead of directly opening
an Access "document" from a shortcut or via browsing with Windows
Explorer, I want to wait and detect when a document is opened.

CurrentProject.Name throws an exception if a document isn't loaded yet,
and you try to access it. I'm trying to find a method that does not
require you to trap an exception.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
Kenneth Courville wrote:
Please review:
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).

By "database", I mean an Access "document": mdb, mde, ade, adp, etc.

Basically, if the user opens Access first, instead of directly opening
an Access "document" from a shortcut or via browsing with Windows
Explorer, I want to wait and detect when a document is opened.

CurrentProject.Name throws an exception if a document isn't loaded yet,
and you try to access it. I'm trying to find a method that does not
require you to trap an exception.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Again, it may be a terminology problem (in addition to the operational
problem you've reported). In Access development an "add-in" is,
usually, an Access "database" file, what you call a document. It is
usually meant to be used as a development aid, though it can be used in
applications. It becomes part of the Access interface/IDE when it is
registered by the Access "Add-in Manager," which is also an add-in (one
of the standard Access wizards). The add-in then becomes part of the
Access environment on the PC on which it was registered.

I'm not sure what I'd call you're program. It sounds like something
that is running BEFORE Access starts, which would mean it'd have to be
"watching" the Windows Messages (using the Windows APIs) to "know" when
Access was loaded; then watch that instance of Access and wait until a
"document" was loaded. This is not an Access "add-in."

Perhaps, the answer lies outside the realm of Access development. There
is an MS newsgroup devoted to C#:

microsoft.public.dotnet.languages.csharp

where you may have more success in finding help.

Rgds,

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQH7ho4echKqOuFEgEQKpjACfVYBSdnVjO2tPljczXVANmx vXCXwAoOTD
S/4Xgk2ohHWEkCw1ornTDe9k
=fqsR
-----END PGP SIGNATURE-----

Nov 12 '05 #6
Maybe I should say "COM Add-in" instead.

These can be built in VB as well, refer to
http://support.microsoft.com/default...b;EN-US;238228

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: bill | last post by:
I am trying to convince a client that dotNet is preferable to an Access project (ADP/ADE). This client currently has a large, pure Access MDB solution with 30+ users, which needs to be upgraded....
1
by: MVM | last post by:
I am creating a form in an Access project, using SQL Server as the backend. The project is linked to two tables, Departments and FixedAssets. The form I am working with is linked to FixedAssets. ...
1
by: damjanu | last post by:
Hi; I have spent some time investigating this issue, and I would like to verify with you my findings. I would greatly appreciate someone experianced saying yes to what I concluded, or no and...
7
by: damjanu | last post by:
Hi All; I need little help. I have a datasheet form. I allow user to do 'filter by selection'. My form contains a column with values. As user changes selections, I want to calculate totals....
0
by: Bob Davies | last post by:
I have an SQL Server database which I have upsized from Access. I have written a Procedure in SQL Server which creates a new table based on joining several other tables. However, Access Project...
6
by: Kenneth Courville | last post by:
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...
11
by: Tim Smallwood | last post by:
Hi, I have an Access project that I use to allow a client to hit an SQL server at my host. This project has several forms that are used to udpate tables, etc, but I'd also like to be able to...
1
by: Jim Devenish | last post by:
I am continuing my exploration about upsizing to SQLServer from Access 2000. I have a split database with a front-end and a back-end, each of which is A2K. I have spent some time in bookshops...
1
by: GAVO-UK | last post by:
Hi - Using Access 2003 I've been creating applications in access for the past few years and gotten pretty good at it, now I would like to move a bit forward and start using ms access project. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.