
functions calling other functions
It's normal for one function to call another. You can do that as
safely and efficiently as using the built-in functions like Int().
The simplest way to handle errors is with error handling in *each*
procedure. Otherwise tracking down where the error occurred can be
awkward. Example:
- Procedure A calls function B.
- A has error handling; B does not.
- An error occurs in B.
- Because B was called from A and error handling is running there,
B returns an error for A to handle.
Now you're told that A is handling an error, but there's nothing
wrong with A, and you don't know where the error occurred. There
are cases where this is useful, but in general it's easier to debug
your application if each procedure has its own error handling.
One of the best side-effects of the approach you suggest is ease of
debugging and maintenance. If the code needs modifying, it's much
easier and safer if you know there's only one place to change than
if you must find and fix multiple ocurrances that could be anywhere.
You'll often need to pass references into the generic procedure.
For example, you can pass a ref to the current form:
Function CheckThis(frm As Form)
End Function
call it like this:
Call CheckThis(Me)
and then use "frm" to refer to any controls/properties of the form.
Quote:
> I have a form in which I want private sub procedures to call a public function in
> a public module which in turn refers (calls?) another function in the same public
> module. Both functions return 0 if there were no errors and various integers if
> there was an error (each type of error will return a different integer). I'm doing
> this to avoid duplicating code. Is there any downside to this scenario and to
> having one function feed into another, especially in terms of error handling?
> Thanks in advance.
> Maureen
--
Perth, Western Australia
Tips for MS Access users at:
http://odyssey.apana.org.au/~abrowne