Re: Common Procedure

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



A common procedure is great idea. However, for ONE LINE of code, I don't
really think it is great benefit.

Further, I would avoid using "domenuItem", as that suggests a particular
version of ms-access, and further a particular menu bar. So, another great
developer suggestion is to AVOID these menu type commands.

To force a disk write, you can use:

me.Refresh

However, the above while only one line of code is better changed with:


if me.Dirty = True then
me.dirty = false
end if

So, the above is 3 lines of code....

Of course, the above uses the built in form reference called "me", and you
can't put that in a standard module. however, you an pass the form name.

Hence, you save code can be:

Call MySave(me)



You standard code module can thus be:


Public Sub MySave(frm as form)

if frm.Dirty = True then
frm.Dirty = false
end if

end sub

Note how by passing the form name, we can simply replace all of our "me"
prefix to "frm", and really just write our code as if it had been in the
"forms" code module. Using the above means we simply pass the form name, and
thus can make "common" code for all forms.

Anyway, try and stay away from those old style menu commands. they are tied
to particular versions, and you only lucky they work because MS works hard
to make those old confusing menu commands still work, but I would not bet my
applications on such syntax....


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@xxxxxxx


.


Quantcast