Receiving Events from MS Access from Custom Toolbar in VB.NET

A

Alain Hogue

Hi everyone!

I have created a toolbar to use in MS Access 2000, 2002, 2003. I would like
to be notified when the user select a new database or close the current one.
Also I would like my toolbar to remain available even if no database is
opened.

I am presently using Interop from a VB.NET AddIn build with the v1.1
Framework. I am also using the PIA Interop dll. I was not able to find any
event raised by Access that I could subscribe to.

I am starting to look at low level API to achieve this.

Please advice!

Thanks!
 
A

Albert D. Kallal

Alain Hogue said:
Hi everyone!

I have created a toolbar to use in MS Access 2000, 2002, 2003. I would like
to be notified when the user select a new database or close the current one.
Also I would like my toolbar to remain available even if no database is
opened.

I would say that you need to build code for each item in the menu bar. In
fact, when I create custom menu bars, or tools bars, I write code for each
option in the toolbar. If you write code for each option, then you certainly
then can come up with some schemes to notify your application.

however, like in c++, or vb, or most environments, there is NOT a event that
fires when you open a file in vb, or c++. and, also this is the same in
ms-access.

So, for most of the menu options, that menu code can (and in fact often
does) call standard code in a module. However, there is NOT a VBA equivalent
of the file open command exposed.
 
A

Alain Hogue

Thanks for answering my post. But this is not exactly my problem.

First I am using a custom toolbar. Access do not allow custom toolbar to
remain available if there is no database opened.
Second, some program, like Excel, raise event when someone open or close a
workbook. Why not Access?
Finaly, when the user close the database, Access just stop showing my
toolbar. I have no way of knowing if a database was closed or not.

Have a nice day!
 
A

Albert D. Kallal

Alain Hogue said:
Thanks for answering my post. But this is not exactly my problem.

First I am using a custom toolbar. Access do not allow custom toolbar to
remain available if there is no database opened.

That is correct. Each mdb represents a application. You could customize the
actual built in ones, but what code could they call?

Second, some program, like Excel, raise event when someone open or close a
workbook. Why not Access?

It is true, both word, and excel do have events for this. However, they are
document orientated systems, where as ms-access is a database. The is a big
difference here (however, I suppose it would be nice to have some event
exposed, but then again, where will the code reside?. If you are using
ms-access as com object, then can certainly see that controlling this event
would be nice..but then again, we are talking about database system, and not
a document orientated system like excel/word. Excel, or word always loads
the WHOLE document into memory, where as ms-access does not. So, in
ms-access, we don't load, or un-load a whole document. Ms-access only loads
PART of a file, or part of the data. So, if you have a large file with 1
million records, and open to ONE record..ONLY that one record is loaded. In
addition, ms-access is multi-user, and once again the concepts of having a
file open, or closed begins to blur a bit as compared to simple document
systems like excel/word). So, while it would be nice..there is quite a few
differences on a conceptual level here when comparing ms-access to
applications like word, excel, power-point, all which work on a SINGLE
document that is LOADED INTO memory. (ms-access does NOT follow this concept
at all, nor does it load the whole data file into memory).

Finaly, when the user close the database, Access just stop showing my
toolbar. I have no way of knowing if a database was closed or not.

That is correct. The work around is to load a invisable form, and use the
close/un-load events of that form
 
D

david epsom dot com dot au

First I am using a custom toolbar. Access do not allow custom toolbar
remain available if there is no database opened.

The people who originally developed Access had in mind a 'relational'
database system, where all the data ABOUT the data in the database
was also stored in the database. That included the menu system,
stored procedures, views, and the keyboard mapping.

(user preferences were stored in a separate user preference database)

Access has since been hacked around to share code with Office and
VBA, but in the main, Office and VBA have not been changed to match
Access, so implementation differences remain.

(david)
 
A

Alain Hogue

Thanks again for sharing all this with me. It dows help (kind of)

The problem I am facing is I am building a generic toolbar to be used in ALL
databases, old and new. This toolbar is build in VB.NET and could be used by
anyone in Access. It provide a interface users can use to connect to
download informations in their current database. There is NO code or form
created in the database at all. The only things I do is create a new table
to store the result of the query (retrieved from within VB.NET from an
external Business Controler using remoting to access data stored in a remote
SQL server)

Now, if I create a button on the Database Toolbar, this button remain
available even if there is no database opened. Access itself have numerous
toolbar available at all time, even if no databases are opened. How can I
hack Access and force my toolbar to be available even if there is no
databases opened?

Thanks!
 
A

Albert D. Kallal

Now, if I create a button on the Database Toolbar, this button remain
available even if there is no database opened. Access itself have numerous
toolbar available at all time, even if no databases are opened. How can I
hack Access and force my toolbar to be available even if there is no
databases opened?

You certainly could modify one of the built in menu bars. I mean, there is a
menu bar called Utility 1, and Utility 2.

You could check to see if any "existing" customizing of these "extra" menus
has been done, if yes:

pull out the changes
delete all the buttions
Put in your buttions
Show the menu.

When you shut down the application, you would have to reverse the above....

In fact, it is VERY rare that people customize utility 1, or utility 2.
(they usually blank). So, you could consider just adding your buttons to the
tool bar. Furhter, when you add your buttions...you can have them NOT be
saved....
 
A

Alain Hogue

Thanks for the info. I did not known the existance of Utility1 and 2. I
suppose I could try using that instead.

You have been very helpfull. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top