how do I use a variable in a report calulation

S

Salli Brackett

My report runs a function when it opens. There are three public variables
that have data which I need to use in the form - the three fields that use
these variables give me an error #name? I cannot determine why it won't
acknowledge these variables.
 
M

Marshall Barton

Salli said:
My report runs a function when it opens. There are three public variables
that have data which I need to use in the form - the three fields that use
these variables give me an error #name? I cannot determine why it won't
acknowledge these variables.


Query and control (text box, etc) expressions only recognize
Public Functions in standard modules.

Either use code in a report section Format event procedure
to set the text box value. or create a function (in the same
module as the public vatiables) that returns the value of a
variable. This kind of function is very simple:

Public MyVar As ...
....
Public Function GetMyVar()
GetMyVar = MyVar
End Function

then you can change your expression from something like
=2 * MyVar + 1
to
=2 * GetMyVar() + 1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top