473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Function vs Sub /Public vs Private

I'm hoping someone can tell me if there is any performance benefit in
my applications between distinguishing a code routine as a Function or
a Sub or if there is a performance benefit between identiying a
Function as a Function or a Private Function (or Sub as a Sub or a
Private Sub) in code modules.

I understand that using Private Functions or Private Subs limits the
scope from which it can be called, but I'm wondering if there is any
speed or overhead benefit in making the distinction.

I know I can't call a Sub using "=SubName()" in the event procedure of
a control, only = "=FunctionName()", so I just got in the habit of
labeling everything as a Function instead.

Thanks,
lq

Nov 13 '05 #1
36 21452
On 18 Jul 2005 08:44:53 -0700, "lauren quantrell"
<la*************@hotmail.com> wrote:
I'm hoping someone can tell me if there is any performance benefit in
my applications between distinguishing a code routine as a Function or
a Sub or if there is a performance benefit between identiying a
Function as a Function or a Private Function (or Sub as a Sub or a
Private Sub) in code modules.
If a value is not being returned, a Sub should be a tiny bit more efficient
than a Function, but I doubt you'll ever notice the difference. Public vs
Private should not be expected to make any difference at all since it's only a
rule, checked at compile-time.
I understand that using Private Functions or Private Subs limits the
scope from which it can be called, but I'm wondering if there is any
speed or overhead benefit in making the distinction.
There shouldn't be.
I know I can't call a Sub using "=SubName()" in the event procedure of
a control, only = "=FunctionName()", so I just got in the habit of
labeling everything as a Function instead.


I consider that poor style (but that's a matter of taste), but I doubt there's
any noticeable performance penalty.

Nov 13 '05 #2
Steve,
Thanks for the reply.

Poor Style refering to labeling everything as a Function instead of a
Sub or Poor Style using =FunctionName() in the event procedure of a
control?

thanks,
lq

Nov 13 '05 #3
"lauren quantrell" <la*************@hotmail.com> wrote in
news:11**********************@z14g2000cwz.googlegr oups.com:
Poor Style refering to labeling everything as a Function instead
of a Sub or Poor Style using =FunctionName() in the event
procedure of a control?


If it's a function, it should be a function.

If it's not, it should be a sub.

Sounds axiomatic, but making every code snippet you write a function
is abdicating your responsibility as a programmer for evaluating the
purpose and use of the code you are writing.

To me, the default is to make a SUB.

You only write a function when you *must*:

- if you must return a single value

- if the code needs to be called in contexts where only functions
work (i.e., macros, etc.).

If you write a sub and later need to use it as function, it's about
1 second's work to change it to a function.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4
David,
Thanks for that but I have to ask, is there any difference in overhead
or performance with having every code snippet a function vs. a sub and
how in evaluating the code will it make a difference? I'm not trying to
be difficult, just trying to decide why and to who it would make any
difference.
Thanks,
lq

Nov 13 '05 #5
lauren quantrell wrote:
David,
Thanks for that but I have to ask, is there any difference in overhead
or performance with having every code snippet a function vs. a sub and
how in evaluating the code will it make a difference? I'm not trying
to be difficult, just trying to decide why and to who it would make
any difference.
Thanks,
lq


Try it. Run a sub in a loop a few hundred times and then run the same code as a
function and see if there's a difference. My guess would be no, but it would
just be a guess.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #6
Rick Brandt wrote:
lauren quantrell wrote:
David,
Thanks for that but I have to ask, is there any difference in overhead
or performance with having every code snippet a function vs. a sub and
how in evaluating the code will it make a difference? I'm not trying
to be difficult, just trying to decide why and to who it would make
any difference.
Thanks,
lq

Try it. Run a sub in a loop a few hundred times and then run the same code as a
function and see if there's a difference. My guess would be no, but it would
just be a guess.


sub is a second faster... after 10,000,000 calls :-)
as an aside, using "call" doesn't make a damn.

Output of code (code below sig)
***
Sub Direct Call: 1.5625
Func Direct Call: 2.671875
Sub Call: 1.625
Func Call: 2.671875

--
[OO=00=OO]

Sub testsubvfunction()
Dim s As Single
Dim i As Long
Const clngTimes As Long = 10000000

Debug.Print "***"

s = Timer
For i = 1 To clngTimes
testsub
Next
Debug.Print "Sub Direct Call: " & Timer - s

s = Timer
For i = 1 To clngTimes
testfun
Next
Debug.Print "Func Direct Call: " & Timer - s

s = Timer
For i = 1 To clngTimes
Call testsub
Next
Debug.Print "Sub Call: " & Timer - s

s = Timer
For i = 1 To clngTimes
Call testfun
Next
Debug.Print "Func Call: " & Timer - s
End Sub
Sub testsub()
Dim a As Long
a = 1
End Sub
Function testfun()
Dim a As Long
a = 1
End Function
Nov 13 '05 #7

Not being dogmatic, I've started running many procedures as functions,
returning a boolean or text. This has improved my program control and
error tracking, since, if the function procedure fails, it returns a
value to the originating routine, allowing me to code for errors, as
well as giving better programmatic control.

Nov 13 '05 #8
On 19 Jul 2005 04:53:50 -0700, "ja********@gmail.com" <ja********@gmail.com>
wrote:

Not being dogmatic, I've started running many procedures as functions,
returning a boolean or text. This has improved my program control and
error tracking, since, if the function procedure fails, it returns a
value to the originating routine, allowing me to code for errors, as
well as giving better programmatic control.


That's sort of a C coding style. Isn't that what exceptions are for, though?
To not clutter the main line of execution with If statements to handle
non-mainline cases?
Nov 13 '05 #9
And to my original point, I use a lot of event procedures to call code
OnClick = "=RunSomeCoolCode()" and these can't be called as subs but
they can be called as functions. In many cases the code called by an
event procedure on one form might also be called from an event
procedure or a command button on other forms. Codig it as a function in
one place streamlines the code and increases opportunities to use it
repeatedly throughout the application.
lq

Nov 13 '05 #10
"lauren quantrell" <la*************@hotmail.com> wrote in
news:11**********************@g43g2000cwa.googlegr oups.com:
And to my original point, I use a lot of event procedures to call
code OnClick = "=RunSomeCoolCode()" and these can't be called as
subs but they can be called as functions. In many cases the code
called by an event procedure on one form might also be called from
an event procedure or a command button on other forms. Codig it as
a function in one place streamlines the code and increases
opportunities to use it repeatedly throughout the application.


You seem to be arguing for an approach that I consider to be
brain-dead stupid. That is, you seem to suggest making every
subroutine a function *just in case* you should ever sometime
between now and the Apocalypse need to use it as a function.

That, to me, constitutes an abdication of one of the most important
jobs of a programmer: to fully consider the scope and use of code as
you're writing it. If you never ask yourself "should this be a sub
or a function?" you may end up not really considering important
issues regarding how the code you are writing is going to be needed,
in what contexts and for what purposes.

Secondly (to repeat myself). it's not like it's *hard* to convert a
subroutine to a function once the need to return a value comes up --
it takes all of one second.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #11
I'm really trying to undertsnad this since others in this thread have
demonstrated how it makes no difference as far as speed or overhead.
So, how does limiting the scope of a bunch of code in a Sub make any
difference beween unlimiting it in a Function? I do make great use of
Private Functions vs. Public Functions to accomplish this.
lq

Nov 13 '05 #12
"lauren quantrell" <la*************@hotmail.com> wrote in
news:11**********************@f14g2000cwb.googlegr oups.com:
I'm really trying to undertsnad this since others in this thread
have demonstrated how it makes no difference as far as speed or
overhead. So, how does limiting the scope of a bunch of code in a
Sub make any difference beween unlimiting it in a Function? I do
make great use of Private Functions vs. Public Functions to
accomplish this.


Because asking yourself "should this be a function or a sub?" frames
the whole issue of what purpose the code serves.

The performance issue has ZILCH to do with it.

If I were picking up someone else's code and found everything was a
function, I'd be severely puzzled trying to figure out why, until I
figured out that it was just a misguided (or incompetent)
programmer.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #13
rkc
lauren quantrell wrote:
And to my original point, I use a lot of event procedures to call code
OnClick = "=RunSomeCoolCode()" and these can't be called as subs but
they can be called as functions. In many cases the code called by an
event procedure on one form might also be called from an event
procedure or a command button on other forms. Codig it as a function in
one place streamlines the code and increases opportunities to use it
repeatedly throughout the application.


To me, using OnClick = "=RunSomeCoolCode()" in a property sheet is an
awful lot like using a lookup field in the design of a table. It
masks the fact that an event is triggering some action. I favour
Call RunSomeCoolCode() in the Event's Sub in the form's code module.
There a sub is a sub and a function is a function.

Nov 13 '05 #14
I agree with you 100% except that in MS Access forms load much faster
when they have no code module, so in general I choose to use OnClick =
"=RunSomeCoolCode()" and avoid having a form code module whenever
possible.

Nov 13 '05 #15
I agree with you 100% except that in MS Access forms load much faster
when they have no code module, so in general I choose to use OnClick =
"=RunSomeCoolCode()" and avoid having a form code module whenever
possible.

Nov 13 '05 #16
rkc
lauren quantrell wrote:
I agree with you 100% except that in MS Access forms load much faster
when they have no code module, so in general I choose to use OnClick =
"=RunSomeCoolCode()" and avoid having a form code module whenever
possible.


I can't argue with that if you have found it actually makes a noticeable
difference. A problem I would have with that personally is that I tend
to document a form's purpose in it's code module.
Nov 13 '05 #17
lauren quantrell wrote:
I agree with you 100% except that in MS Access forms load much faster
when they have no code module, so in general I choose to use OnClick =
"=RunSomeCoolCode()" and avoid having a form code module whenever
possible.


That was the hype when "light forms" were introduced, but I have never noticed a
difference.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #18
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:uC*******************@twister.nyroc.rr.com:
lauren quantrell wrote:
And to my original point, I use a lot of event procedures to call
code OnClick = "=RunSomeCoolCode()" and these can't be called as
subs but they can be called as functions. In many cases the code
called by an event procedure on one form might also be called
from an event procedure or a command button on other forms. Codig
it as a function in one place streamlines the code and increases
opportunities to use it repeatedly throughout the application.


To me, using OnClick = "=RunSomeCoolCode()" in a property sheet is
an awful lot like using a lookup field in the design of a table.
It masks the fact that an event is triggering some action. I
favour Call RunSomeCoolCode() in the Event's Sub in the form's
code module. There a sub is a sub and a function is a function.


Well, it's awfully handy to select a bunch of controls and type a
single function into the same event for all of them. It's much
harder to do the same in VBA.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #19
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:ff*******************@twister.nyroc.rr.com:
lauren quantrell wrote:
I agree with you 100% except that in MS Access forms load much
faster when they have no code module, so in general I choose to
use OnClick = "=RunSomeCoolCode()" and avoid having a form code
module whenever possible.


I can't argue with that if you have found it actually makes a
noticeable difference. A problem I would have with that personally
is that I tend to document a form's purpose in it's code module.


I've never seen any noticeable difference in peformance with
module-less forms.

Didn't someone benchmark this way back when A2K first came out (the
first version that allowed you to set the HasModule property to
False), and find that there was virtually no difference in load time
for these lightweight, module-less forms?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #20
rkc
David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:uC*******************@twister.nyroc.rr.com:

lauren quantrell wrote:
And to my original point, I use a lot of event procedures to call
code OnClick = "=RunSomeCoolCode()" and these can't be called as
subs but they can be called as functions. In many cases the code
called by an event procedure on one form might also be called
from an event procedure or a command button on other forms. Codig
it as a function in one place streamlines the code and increases
opportunities to use it repeatedly throughout the application.


To me, using OnClick = "=RunSomeCoolCode()" in a property sheet is
an awful lot like using a lookup field in the design of a table.
It masks the fact that an event is triggering some action. I
favour Call RunSomeCoolCode() in the Event's Sub in the form's
code module. There a sub is a sub and a function is a function.

Well, it's awfully handy to select a bunch of controls and type a
single function into the same event for all of them. It's much
harder to do the same in VBA.


I almost mentioned that, then figured it was a given. I personally
have a tendency to wrap that type of behavior in a class instead.

Nov 13 '05 #21
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:Nz******************@twister.nyroc.rr.com:
David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:uC*******************@twister.nyroc.rr.com:
lauren quantrell wrote:

And to my original point, I use a lot of event procedures to
call code OnClick = "=RunSomeCoolCode()" and these can't be
called as subs but they can be called as functions. In many
cases the code called by an event procedure on one form might
also be called from an event procedure or a command button on
other forms. Codig it as a function in one place streamlines the
code and increases opportunities to use it repeatedly throughout
the application.

To me, using OnClick = "=RunSomeCoolCode()" in a property sheet
is an awful lot like using a lookup field in the design of a
table. It masks the fact that an event is triggering some action.
I favour Call RunSomeCoolCode() in the Event's Sub in the form's
code module. There a sub is a sub and a function is a function.


Well, it's awfully handy to select a bunch of controls and type a
single function into the same event for all of them. It's much
harder to do the same in VBA.


I almost mentioned that, then figured it was a given. I personally
have a tendency to wrap that type of behavior in a class instead.


That's substantially more work for what seems to me to be very
little benefit.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #22
rkc
David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:Nz******************@twister.nyroc.rr.com:

David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:uC*******************@twister.nyroc.rr.com :
lauren quantrell wrote:
>And to my original point, I use a lot of event procedures to
>call code OnClick = "=RunSomeCoolCode()" and these can't be
>called as subs but they can be called as functions. In many
>cases the code called by an event procedure on one form might
>also be called from an event procedure or a command button on
>other forms. Codig it as a function in one place streamlines the
>code and increases opportunities to use it repeatedly throughout
>the application.

To me, using OnClick = "=RunSomeCoolCode()" in a property sheet
is an awful lot like using a lookup field in the design of a
table. It masks the fact that an event is triggering some action.
I favour Call RunSomeCoolCode() in the Event's Sub in the form's
code module. There a sub is a sub and a function is a function.

Well, it's awfully handy to select a bunch of controls and type a
single function into the same event for all of them. It's much
harder to do the same in VBA.


I almost mentioned that, then figured it was a given. I personally
have a tendency to wrap that type of behavior in a class instead.

That's substantially more work for what seems to me to be very
little benefit.


Suppose you have several textbox controls that you want to
1) change color on focus
2) change color on lost focus
3) validate input when changed
4) follow behaviour rules stored outside the code
5) react to certain events in other textbox controls

Would you write multiple functions and set event properties
or would you write a class, initialise the required number
of instances and manage them via a collection? Which is
more work? Which would be easier to modify? If you were
hit by a NYC bus which would make your successor happier?




Nov 13 '05 #23
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:_l*******************@twister.nyroc.rr.com:
David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:Nz******************@twister.nyroc.rr.com:

David W. Fenton wrote:

rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:uC*******************@twister.nyroc.rr.co m:
>lauren quantrell wrote:
>
>
>>And to my original point, I use a lot of event procedures to
>>call code OnClick = "=RunSomeCoolCode()" and these can't be
>>called as subs but they can be called as functions. In many
>>cases the code called by an event procedure on one form might
>>also be called from an event procedure or a command button on
>>other forms. Codig it as a function in one place streamlines
>>the code and increases opportunities to use it repeatedly
>>throughout the application.
>
>To me, using OnClick = "=RunSomeCoolCode()" in a property sheet
>is an awful lot like using a lookup field in the design of a
>table. It masks the fact that an event is triggering some
>action. I favour Call RunSomeCoolCode() in the Event's Sub in
>the form's code module. There a sub is a sub and a function is
>a function.

Well, it's awfully handy to select a bunch of controls and type
a single function into the same event for all of them. It's much
harder to do the same in VBA.

I almost mentioned that, then figured it was a given. I
personally have a tendency to wrap that type of behavior in a
class instead.

That's substantially more work for what seems to me to be very
little benefit.


Suppose you have several textbox controls that you want to
1) change color on focus
2) change color on lost focus
3) validate input when changed
4) follow behaviour rules stored outside the code
5) react to certain events in other textbox controls

Would you write multiple functions and set event properties
or would you write a class, initialise the required number
of instances and manage them via a collection? Which is
more work? Which would be easier to modify? If you were
hit by a NYC bus which would make your successor happier?


Well, you've substantially upped the bar on the kind of
functionality I was thinking about.

And whether a future programmer likes it or not depends entirely her
level of expertise. Plenty of people making their living as Access
programmers wouldn't be able to figure out how it is accomplished.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #24
rkc
David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:_l*******************@twister.nyroc.rr.com:

David W. Fenton wrote:
Plenty of people making their living as Access
programmers wouldn't be able to figure out how it is accomplished.


Plenty of people making their living as Access programmers don't
know how to sort "e;b;c;d;a;g" alphabetically. Hopefully any
client smart enough to hire ya'll would be smart enough to replace
ya'll with one who did.
Nov 13 '05 #25
Bri

lauren quantrell wrote:
I'm really trying to undertsnad this since others in this thread have
demonstrated how it makes no difference as far as speed or overhead.
So, how does limiting the scope of a bunch of code in a Sub make any
difference beween unlimiting it in a Function? I do make great use of
Private Functions vs. Public Functions to accomplish this.
lq


I'm not sure if this is true, but it seems logical (at least to me). It
may be faster to have the Function declared Public if it is called
frequently. I think that Public Functions (or Subs) are loaded into
memory on initial loading of the app and they stay in memory. Private
ones are only loaded when they are called. So it seams to be a case of
which overhead causes more/less performance; more memory consumed or
loading of private at runtime. With today's PCs with tons of RAM, it
might favour loading everything at the start

--
Bri
Nov 13 '05 #26
"David W. Fenton" wrote
I've never seen any noticeable
difference in peformance with
module-less forms.


Mike Groh, Tech Editor of Access Advisor, tested Forms with the largest
possible Modules versus Forms without Modules when they were first released,
and highly hyped as "faster". He found, and published, that the difference
was in the range of 5 - 15 milliseconds. That is, of course, far to small to
be perceptible to the user looking at the Form opening on a display screen.

That kind of time difference would only be of consequence in a loop,
repeated many times, and that is not how Forms are opened.

To Microsoft's credit, I have not seen them hyping codeless Forms since that
was published.

Larry Linson
Microsoft Access MVP
Nov 13 '05 #27
"rkc" wrote
Plenty of people making their living as
Access programmers don't know how
to sort "e;b;c;d;a;g" alphabetically.
Hopefully any client smart enough to
hire ya'll would be smart enough to
replace ya'll with one who did.


I'd warrant that my clients have all been smart enough to hire developers
whose talents and cost matched their needs. I've been in the computer
business since 1958 and have rarely run across a valid real-world
requirement to sort in anything other than "normal" sequences on maiframes,
minicomputers, or micros.

And, when I did, it was always "names of something" in the order that people
normally thought of them... trivially simple to handle. The few people I
ever worked with who were not smart enough to use a "sort order" field or
function didn't last long in the programming (or development) business,
anyway.

Larry Linson
Microsoft Access MVP
Nov 13 '05 #28
I initially bought into the light-form hype, and have never gone back.
(When I ran my li'l tests years back, it made a huge difference, but I
sure don't consider "because I remember it that way" a benchmark.)

I stayed with it because I don't think assembling a bunch of VBA code
in a form module constitutes organization. (In fact, I *hate* forms'
modules, and avoid them like the plague, for many reasons which don't
bear mention here.) The events are all right there in the little
property sheet to look at. And as far as I can tell, clicking the
little Build button in the property sheet next to an event, jumping to
a well-structured public procedure in an appropriately grouped module
is a lot quicker than opening the #%!$%% module of the form and hitting
SHIFT+F2 a bunch of times. The user, of course, will never know the
difference. (Except my forms load a little faster ;).)

Furthermore, at the point at which you're building classes, you're
outside the form space anyway, logically and literally.

Does all this mean I have some Functions that should be Subs? Yep. And
I'm willing to bet you fifty bucks and a team of mules I've got some
Subs that could very easily become Functions, too. Doesn't mean I
don't think about it, but I enjoy sleep and leisure activities outside
of programming as well.

Nov 13 '05 #29
rkc
downwitch wrote:
Does all this mean I have some Functions that should be Subs? Yep. And
I'm willing to bet you fifty bucks and a team of mules I've got some
Subs that could very easily become Functions, too. Doesn't mean I
don't think about it, but I enjoy sleep and leisure activities outside
of programming as well.


What do you use the mules for? To set in your ways to buy a tractor?
Nov 13 '05 #30
"lauren quantrell" wrote
I agree with you 100% except that
in MS Access forms load much faster
when they have no code module, . . .


No, they don't -- not unless you consider 5 - 15 milliseconds "much faster".
It was a good idea that just didn't prove out. See my response to David,
later in the thread, about Mike Groh's testing and published results.
Nov 13 '05 #31
Larry Linson wrote:
Mike Groh, Tech Editor of Access Advisor, tested Forms with the largest
possible Modules versus Forms without Modules when they were first released,
and highly hyped as "faster". He found, and published, that the difference
was in the range of 5 - 15 milliseconds. That is, of course, far to small to
be perceptible to the user looking at the Form opening on a display screen.


Hey, my clients are drumming their fingers on the table well before that :-)

--
[OO=00=OO]
Nov 13 '05 #32
rkc wrote:
downwitch wrote:
Does all this mean I have some Functions that should be Subs? Yep. And
I'm willing to bet you fifty bucks and a team of mules I've got some
Subs that could very easily become Functions, too. Doesn't mean I
don't think about it, but I enjoy sleep and leisure activities outside
of programming as well.


What do you use the mules for? To set in your ways to buy a tractor?


Counterstubbornness.

Nov 13 '05 #33
Larry,
Maybe I formed that opinion back in Access 97 and have it stuck in my
mind. I can remember loading forms with a couple of subforms and when I
removed all the OnLoad, OnOpen, populating and control formatting code
into a module named after the form (to keep it all in one place) I
could count the difference with the second hand on my watch.
Maybe it got changed but I kept the notion it makes a difference and
have stuck with that contruction since those dark days.

Nov 13 '05 #34
"lauren quantrell" <la*************@hotmail.com> wrote in
news:11**********************@g14g2000cwa.googlegr oups.com:
Maybe I formed that opinion back in Access 97 and have it stuck in
my mind. I can remember loading forms with a couple of subforms
and when I removed all the OnLoad, OnOpen, populating and control
formatting code into a module named after the form (to keep it all
in one place) I could count the difference with the second hand on
my watch. Maybe it got changed but I kept the notion it makes a
difference and have stuck with that contruction since those dark
days.


Sounds like your forms weren't properly compiled and were
recompiling each time they were loaded.

That's a completely different set of problems that can be solved
without moving all the code out of the forms.

And it may be due to hidden corruption -- decompile (judiciously
used) is your friend.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #35

David W. Fenton wrote:
"lauren quantrell" <la*************@hotmail.com> wrote in
news:11**********************@g14g2000cwa.googlegr oups.com:
Maybe I formed that opinion back in Access 97 and have it stuck in
my mind. I can remember loading forms with a couple of subforms
and when I removed all the OnLoad, OnOpen, populating and control
formatting code into a module named after the form (to keep it all
in one place) I could count the difference with the second hand on
my watch. Maybe it got changed but I kept the notion it makes a
difference and have stuck with that contruction since those dark
days.


Sounds like your forms weren't properly compiled and were
recompiling each time they were loaded.

That's a completely different set of problems that can be solved
without moving all the code out of the forms.

And it may be due to hidden corruption -- decompile (judiciously
used) is your friend.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc


Okay, I'll bite. I have never heard of a form being "compiled", in ten
years of (almost) pure Access development, across the wide web of the
world and numerous manuals. What, exactly, is a compiled form?

And I decompile _mdb files_ as often as you please--as do a number of
other scamps about these parts--with nary a side effect I could name.
So please, elaborate. With hyperlinked backup, de preférence.

Nov 13 '05 #36
"downwitch" <do*******@gmail.com> wrote in
news:11**********************@z14g2000cwz.googlegr oups.com:
David W. Fenton wrote:
"lauren quantrell" <la*************@hotmail.com> wrote in
news:11**********************@g14g2000cwa.googlegr oups.com:
> Maybe I formed that opinion back in Access 97 and have it stuck
> in my mind. I can remember loading forms with a couple of
> subforms and when I removed all the OnLoad, OnOpen, populating
> and control formatting code into a module named after the form
> (to keep it all in one place) I could count the difference with
> the second hand on my watch. Maybe it got changed but I kept
> the notion it makes a difference and have stuck with that
> contruction since those dark days.
Sounds like your forms weren't properly compiled and were
recompiling each time they were loaded.

That's a completely different set of problems that can be solved
without moving all the code out of the forms.

And it may be due to hidden corruption -- decompile (judiciously
used) is your friend.


Okay, I'll bite. I have never heard of a form being "compiled",
in ten years of (almost) pure Access development, across the wide
web of the world and numerous manuals. What, exactly, is a
compiled form?


Every form with code is compiled to be run. The code you type is
compiled into a p-code symbolic form that is interpreted by the
Access executables.

If a form's module has not been compiled when the form is opened,
Access does the compiling on the fly. But somehow it doesn't always
get flagged as compiled and then recompiles each time you open the
form. This is because there are a whole host of levels of
compilation in an Access project:

The real deal on the /Decompile switch
http://trigeminal.com/usenet/usenet004.asp?1033

Pay special attention to the discussion of the "11 states of of
compilation."
And I decompile _mdb files_ as often as you please--as do a number
of other scamps about these parts--with nary a side effect I could
name. So please, elaborate. With hyperlinked backup, de
preférence.


If you decompile regularly, and are doing it proberly, then you
shouldn't be having code corruption.

If you're still having problems (and I've seen them survive
decompiles, occasionally), you can use Application.SaveAsText and
Application.LoadFromText to rebuild all your code-bearing objects.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #37

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: vijay | last post by:
Hello I wanted to understand a contradictory design of C++ class A {public: virtual void f(){ cout<<" base f"<<endl; } }; class B:public A {
1
by: Saeed Amrollahi | last post by:
Dear All C++ Programmers Hello I am Saeed Amrollahi. I am a software engineer in Tehran Sewerage Company. I try to use std::map and map::find member function. I use Visual Studio .NET. my...
3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
6
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the...
11
by: sebplays | last post by:
Hi, I seach function for clear screen in VB.Net for console application. Please help me
2
by: pangel83 | last post by:
I've been trying for days to write a piece of VB.NET code that will read from winamp's memory space the paths of the files from the current winamp playlist. The GETPLAYLISTFILE command of the...
1
by: CES | last post by:
All, I was wondering if someone could point me to a tutorial on creating & accessing functions from within a wrapper function. I've created a group of functions related to a timer event. All...
10
by: Raj | last post by:
I need a VB function to return array of collections like Private Type Employee empname as string address as string salary as integer deptno as integer End Type dim employees() as Employee
27
by: milestogofromhere | last post by:
I am new to OO PHP and this is probably something really stupid, I have the following code in redirect.php: <?php include("include_functions.php"); include("classes.xhtml.php");...
3
by: mrosado | last post by:
Hi everybody, I have this problem.- The browser launch this two errors: Warning: session_start() : Cannot send session cache limiter - headers already sent (output started at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.