Click to See Complete Forum and Search --> : Functions and sql questions


January 18th, 2000, 02:05 PM
I have two questions. The first is about functions.

1. Functions
Wich is the best place for a function a form or a module(bas)?.
I'm interested in memory and speed of my functions.
Which are the main differences between both places?.

2. Crystal Report
I'm using Crystal Report 7.0 and I want to know if it's
possible to make a field in my report that contains a query.
I want to make a "select sum" in one table and I want a field
to show the result of that query. Is it possible?.
I'm trying using a "sql expresion field" but I don't have success. Any advive???.

Thank you very much

Nauj

Lakshmi Ram
January 18th, 2000, 09:33 PM
1. If you are very sure that the function is very specific to the form and can never be put to use by any other forms or modules, it is wiser to have it within that form,
If you foresee that any other form can make use of this function, try and generalise it so that other forms or modules can make best use of it and move it to a module. That saves you from defining functions for very similar purpose in differenct forms.
The main difference here is re-usability.
If placed at Module level, you are foregoing a little bit of memory which is not of any concern nowadays with a default 96MB++ ram sizes. But making use of the very same function from any other forms or modules.

If placed at Form level, you are releasing memory and localising the function to that specific form, thereby not having anything that is not of common use at a module level.

2. Yes, you cannot have an sql query as the function definition. But since you are saying you already have the field for summation in a datatable, just add that table to your report using the menu option to Add datatables and add the datafield with summation option to the report. Hope this helps...

Cheers
Lakshmi Ram



SNB