>Hi everyone,
>
>I'm writting a statistics program and this is my problem: I want to create 3 sets of statistical calculated values: for source='S' field names should end on 'pur' - purchase, for source='M' 'ref' - refinance, and for no matter that source (eithier S or M) 'all'.
>
>Currently I didn't find a better solution, than create RunAll, RunPur and RunRef functions, which are almost identical except I use different appropriate field names and in two first cases where condition. Unfortunately, this makes my life very hard, if I want to change code. I have to make the same changes in all three functions.
>
>Do you have better ideas for me? I'd like to avoid macros if possible.
>
If S records only have pur fields, and M records only have ref fields, and they're otherwise the same, I'd refactor the database, so that there's a master record that indicates the type of source, and a child that has the fields without any prefix that carry the PKey of the master record. You end up with fewer fields, all the queries will use the same query, with only the source code varying, the data is smaller, new types can be added without altering the structure of the database, and if it's possible for more than one occurance of detail for a master record, there's a simple way to allow it without altering the tables or queries significantly. The reports are the same, except for a heading that you could pass as a variable. The result is that you call the same procedure three times with different parameters, rather than three distinct modules, uses less disk space, and is easier to maintain.
>Thanks in advance.