variable not appearing in report

  • Thread starter Thread starter Marc Miller
  • Start date Start date
M

Marc Miller

I have a function in a module and call it from a text field in
a report, yet I keep getting a value of 0 for the variable.

I tried it on a real production report in Access 2000 and then I created a
test
in Access 2003. Both have the same behavior. Here is what I have


Module -

Public myVar as integer

Public function getNum() as integer

myVar = 55
End Function


In the report I have a text field that contains:

=getNum()

It returns 0.

Any help would be quite appreciated.

Thanks,
Marc Miller
 
You have to assign the value to the function in order to return it

Public function getNum() as integer

myVar = 55
GetNum = myVar

'As simple as this is you could just use
' GetNum = 55

End Function
 
Marc said:
I have a function in a module and call it from a text field in
a report, yet I keep getting a value of 0 for the variable.

I tried it on a real production report in Access 2000 and then I created a
test
in Access 2003. Both have the same behavior. Here is what I have

Module -

Public myVar as integer

Public function getNum() as integer

myVar = 55
End Function


In the report I have a text field that contains:

=getNum()

It returns 0.


You must use the function's name to return its value:

Public function getNum() as integer

myVar = 55
getNum = myVar

End Function
 
Gentlemen,

Thank you! Life is much better now. MSAccess never ceases to amaze me.

Regards,
Marc Miller
 
Back
Top