mkasson
Programmer
- Jan 3, 2004
- 36
Each record in my database has about 40 fields that are used in several calculations.
I created a form that uses a bunch of functions that do the calculations that I need. Because there are so many fields that the functions make reference to, I don't pass the values to the functions as arguments; the functions make reference to the fields on Me (e.g. [S1Amt], [S1Date],[S2Amt]).
Now I'm trying to generate reports and I need to use these or similar functions. I've tried putting functions in the code for the report. When I tried testing this by putting a test function (Add2) in a report ("=Add2()"), it prompted me with a box asking for a value for Add2. Add2 was defined as a public function in the report's code module.
I tried putting Add2 in the Project's Module1. Now the report can find the function, but it won't let me just refer to the current record's fields (e.g. [S1Amt]).
How can I have functions that use the current record's field values without having them passed as arguments?
And can't a report have a code module for local functions?
Ideally there would be a way to create these functions once rather than having to create almost identical functions for the form and the report.
Thanks much.
-MSK
- MSK
I created a form that uses a bunch of functions that do the calculations that I need. Because there are so many fields that the functions make reference to, I don't pass the values to the functions as arguments; the functions make reference to the fields on Me (e.g. [S1Amt], [S1Date],[S2Amt]).
Now I'm trying to generate reports and I need to use these or similar functions. I've tried putting functions in the code for the report. When I tried testing this by putting a test function (Add2) in a report ("=Add2()"), it prompted me with a box asking for a value for Add2. Add2 was defined as a public function in the report's code module.
I tried putting Add2 in the Project's Module1. Now the report can find the function, but it won't let me just refer to the current record's fields (e.g. [S1Amt]).
How can I have functions that use the current record's field values without having them passed as arguments?
And can't a report have a code module for local functions?
Ideally there would be a way to create these functions once rather than having to create almost identical functions for the form and the report.
Thanks much.
-MSK
- MSK