Run Code every Time any form is loaded in the database.

  • Thread starter Thread starter news.bellnet.ca
  • Start date Start date
N

news.bellnet.ca

I want to run the following code every time a form is loaded or unloaded,
without adding code to every form in my database. Any ideas?

DoCmd.ShowToolbar "NoMenu", acToolbarNo

I have just too many forms to add same code to all of them individually.

Thanking everyone in anticipation.

Sincerely,

Naveed
 
I want to run the following code every time a form is loaded or unloaded,
without adding code to every form in my database. Any ideas?

DoCmd.ShowToolbar "NoMenu", acToolbarNo

I have just too many forms to add same code to all of them individually.

Thanking everyone in anticipation.

Sincerely,

Naveed

The only short way to do it is to create a public function in a
Module:

Public Function KillToolbar()
DoCmd.ShowToolbar "NoMenu", acToolbarNo
End Function

and put

=KillToolbar()

onto the Load event line in every form (you can skip subforms since
they don't have toolbars).


John W. Vinson[MVP]
 
I considered a similar response, but that still involves modifying every
form. I wonder what the whole purpose of doing this could be.
 
news.bellnet.ca said:
I want to run the following code every time a form is loaded or unloaded,
without adding code to every form in my database. Any ideas?

DoCmd.ShowToolbar "NoMenu", acToolbarNo

I have just too many forms to add same code to all of them individually.


Why don't you just make the above menu the "main" menu bar....and it will
always show anyway.

You do NOT need to write code to show/hide menus....

Any form that needs a different, or special menu bar simply needs to have
that menu bar specified in the "other" tab of the properties sheet.

For all forms that "default" to your above example menu bar...simply leave
the setting blank..and all forms will show that menu bar.

Your mess here is that you are trying to write code to show/hide menu
bars..and if you do this correct...it is 100% automatic in ms-access, and NO
code is needed.

Try downloading and running the 3rd example at my following web site that
shows a hidden ms-access interface, and NO CODE is required to do
this....but just some settings in the start-up.

Check out:

http://www.members.shaw.ca/AlbertKallal/msaccess/DownLoad.htm

notice how menu bars change when you change forms...and all ms-access stuff
is hidden. This takes NO CODE!!!! So, take a look at the startup
settings..and then take a look at the forms "other" settings. You do NOT
need code here!!
 

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

Back
Top