Please help - Calling functions from reports

thrainpa

Registered User.
Local time
Today, 02:04
Joined
Dec 1, 2011
Messages
29
[SOLVED] Please help - Calling functions from reports

This has now been resolved, thank you RainLover and MSAccessRookie!

Hi, in a report I made a public function like "Public Function FuncName() As String"
and in the function I have set FuncName to "1" as a test.
Then in a text box in the report i called " =FuncName() " But it's not returning "1", it's returning "#Name", but on another report I have done the same thing and it worked perfectly, could there be any reason for this?
 
Last edited:
Have you got different Names for each Function.

Just guessing here.
 
Hi, in a report I made a public function like "Public Function FuncName() As String"
and in the function I have set FuncName to "1" as a test.
Then in a text box in the report i called " =FuncName() " But it's not returning "1", it's returning "#Name", but on another report I have done the same thing and it worked perfectly, could there be any reason for this?

Where is the Public Function located? It sounds like it might be in the Code behind the Report that works. A Public Function should not be located in the Code Behind any Report or Form. It needs to be in a common Module. If it is in the code behind, move it to a common Module.
 
Where is the Public Function located? It sounds like it might be in the Code behind the Report that works. A Public Function should not be located in the Code Behind any Report or Form. It needs to be in a common Module. If it is in the code behind, move it to a common Module.

It is in the code behind the report, I will try putting it in a common module then but then thing is, the other report I in which the function works has said function in the code behind the report. :s
 
How many copies of this Function do you have.

You should only have ONE and that should be stored in a Separate Module.

If you are still having problems then please post a Copy of your Function.

Post the complete Function. Do not leave anything out.
 
How many copies of this Function do you have.
You should only have ONE and that should be stored in a Separate Module.
If you are still having problems then please post a Copy of your Function.
Post the complete Function. Do not leave anything out.

One copy of each function, both with different names, as they do different things, they are in no way connected. I'm sorry if I didn't make this clear.

Just to make sure I'm clear too, in the working example, the function returns to a single source (A report in the format of a letter to return the address);
In the report that the other function is in that does not work, is it being called by a normal recordset-type report, so in the working example, the function runs only once, but in the non-working example, the function could run from 1 to 100 times.

I'm afraid I would not be able to post the function here unless I completely re-write it in a sort of universal format, due to restrictions.
-----------------------------------
I have just tried to run the function from a public module and it works, thanks you so much!

But I have one more question, the other code referenced a local variable to the report (from the reports the record source) Can it still do that in a public function? The answer to this is no. >.<

Is there any way I can make this function refer to each specific record as the report goes through them?
-------------------------------------
I have figured it out!
I have learned that referring to a specific field in the form which actually holds the [Number] Variable actually only ever refers to the specific record it's pulling at the time, it works now!
Thank you so much for your help! I will remember this to help any others with this problem in the future. :P
 
Last edited:

Users who are viewing this thread

Back
Top Bottom