Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

Using a module to control multiple Forms' events

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mark_aok@hotmail.com - 08 Jun 2007 20:29 GMT
Hi all,

I have a navigation bar which exists on nearly all of my forms.  It
has buttons to create new items, to search for items, etc.

But to make my navigation bar functional, I need to copy and paste the
EXACT same event code into about 15 forms - incredibly smelly code.
So I was wondering if anyone knows if I can use a module to set a
control's event code.   Anyone know if this is possible in Access
2003??

Thanks,
Mark
Marshall Barton - 11 Jun 2007 04:41 GMT
>I have a navigation bar which exists on nearly all of my forms.  It
>has buttons to create new items, to search for items, etc.
[quoted text clipped - 4 lines]
>control's event code.   Anyone know if this is possible in Access
>2003??

What's a navigation bar?

If it's a set of command buttons (or other controls) that
you copy/paste onto all those forms, then you can put all
the code in a standard module and make sure each procedure
is a Public Function.

Then you call the appropriate function procedure from the
control's event properties using the syntax =functionname()
instead of [Event Procedure]

If your code is not really **exactly** the same, you will
need to make some changes depending on what the differences
happen to be.  Note that you will not be able to use Me in
this arrangement, instead either pass the form object to the
functions with this syntax  =functionname(Form) or the
functions can refer to  Screen.ActiveForm.  Control names
are usually an issue in this kind of scenario, but maybe not
in your situation.

Signature

Marsh
MVP [MS Access]

mark_aok@hotmail.com - 11 Jun 2007 15:03 GMT
> mark_...@hotmail.com wrote:
> >I have a navigation bar which exists on nearly all of my forms.  It
[quoted text clipped - 29 lines]
> Marsh
> MVP [MS Access]

Ok thanks, I'll but the code in a module.  That really is frustrating
though, how there is no more efficient way of doing this.  It's
probably going to take half a day of copy and pasting.  Oh well,

Mark
Douglas J. Steele - 11 Jun 2007 15:54 GMT
>> mark_...@hotmail.com wrote:
>> >I have a navigation bar which exists on nearly all of my forms.  It
[quoted text clipped - 13 lines]
> though, how there is no more efficient way of doing this.  It's
> probably going to take half a day of copy and pasting.  Oh well,

Note that if you select multiple controls, you can set the event's property
for all of the selected controls at once through the Properties window.
(doesn't work for multiple forms, unfortunately).

You can also set properties programmatically. For example, if the form's
open, you can set the Click event to run your function using:

Forms!NameOfForm!NameOfButton.OnClick = "=functionname()"

(Note that the equal sign inside the quotes and the parentheses must be
there)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

Marshall Barton - 11 Jun 2007 15:58 GMT
>> mark_...@hotmail.com wrote:
>> >I have a navigation bar which exists on nearly all of my forms.  It
[quoted text clipped - 29 lines]
>though, how there is no more efficient way of doing this.  It's
>probably going to take half a day of copy and pasting.  Oh well,

What??

Why do you think you need to do all that copying and
pasting?  My suggestion only needed **one** copy of the code
in a **standard** module instead of every form's class
module.

You still haven't explained what this "navigation bar" is,
so I don't even know if my suggestion even applies to what
you are trying to do.

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.