Which is more efficient?

T

ThriftyFinanceGirl

Which is faster?

Calculating an expression in a control on a report or
Creating a function and calling the function inside the control?

Does it make any difference?
 
C

Chris O'C via AccessMonster.com

Calculating an expression inside the control is faster (because the extra
step to call a public function isn't made), but the time difference is so
small it's not noticeable.

Chris
 
J

Jack Leach

Where possible, you probably want to calculate the expression rather than
refer it to a function.

The reason for this is that each function you call from a form or report
needs to be public... your entire project will be able to see it, and that's
going to take up more overhead.

I believe calculated expressions are handled a bit more navitely as well
(e.i. access has everything all in place ready to go when it needs it, rather
than having to locate your public function, pass the values, etc.)

This probably depends on the information being processed, but that's my
general take on it (FWIW, I'm no guru...)

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
D

Dirk Goldgar

Jack Leach said:
Where possible, you probably want to calculate the expression rather than
refer it to a function.

The reason for this is that each function you call from a form or report
needs to be public... your entire project will be able to see it, and
that's
going to take up more overhead.

Interestingly, this turns out not to be true. In a form, at least -- I
haven't tried this with a report -- you can create a private function in the
form's module and call it from the controlsource of a control on the form.
Yet the function really is private to the form, and other modules can't see
it.
 
C

Chris O'C via AccessMonster.com

The entire project won't see it at all until a proc or property in that
module is called, then the entire module is loaded into memory. If the rest
of the project doesn't need any of the procs or properties in this module, it
doesn't get loaded, so there's no extra overhead. Putting the function in
its own module would eliminate the chance the function would be loaded into
memory only because some other function in the module was called.

Chris
 
T

ThriftyFinanceGirl

Thanks Guys, this is all great information and helps me now and in the future!
 
Top