Harvey said:
Now I'm confused. this is just the problem I have been having - accessing
public methods in a Form module. That does not work. Only when I create
an
envelope method in a regular, non-form module am I able to access the
original form-based routine.
You simply declare the function as public in the forms module..and the menu
will use that one.
You MUST declare the function as public in the forms code for this to work.
I going to repeat my post again:
<quote>
note that this is a real bonus feature, since then you can use the SAME menu
bar for different forms. The menu bar will call the public function into he
FORM THAT HAS the focus. Further, if no public function is found in the form
with the focus, then he standard code modules are then searched...which is
also an great feature..since if you DO NOT add the public function to the
form, then you GENERAL CATCH all function is written. When you start to use
this...you will find it a VERY nice feature of ms-access.
</quote>
Note that the form MUST HAVE the focus. (else, how would ms-access know
which one to call!!!). So, you can well use a public function in the menu
bar..and it can all a public function in the form. In fact, this *is* the
best approach here. Why put code in some un-related module some where else?
If the code belongs to the particular form..then that code should be placed
in the form. It makes logical sense, and from a maintains point of view it
also makes sense.
For example, all of my forms have a public function called MyDelete().
eg:
Public Function MyDelete()
' code here to delete the record...sometimes some special checking..and
special code needs to be run...
End Function
However, for a lot forms, why write delete code over and over? So, in a main
standard code module..I ALSO HAVE a function called MyDelete(). This way, if
the form needs special delete code...I put the code in the forms module. If
the form does NOT need any code..then the general "catch all" mydelete
function in the standard code module is used. This is exactly the behavior I
would
want...
This means for ever more when I build menubars I simply assume that all my
forms will can then have a delete option in the menu bar. Further, if the
form that has the focus DOES NOT have a public function, then the standard
code modules are searched for the function!
Remember, the key here in that in the menu bar "on action", you DO NOT use
the forms! qualifier (if you do..the 3 times bug will rear its ugly head).
So, in the menu bars delete option, the on action would be set to
=MyDelete()
All in all, how this works is a ideal desing....
Here is some more screen shots of menus in ms-acces..and they all use the
above concepts..
http://www.members.shaw.ca/AlbertKallal/Articles/UseAbility/UserFriendly.htm