Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public vars

Status
Not open for further replies.

easycode

Programmer
Jan 28, 2005
195
US
i have defined a public var in a module

mymodule
public tempvar as string

----------------------------------
in the event open of the report i have assigned a value.

Private Sub Report_Open(cancel As Integer)
tempvar = "12345"
End Sub

-----------------------------------------
however im am getting the next window error, whe i run the report.

Enter Parameter Value
tempvar:


it means that the public var is not public, but is local?
Can anyone advise. Thanks a lot.


 
You may try something like this:
mymodule
Public tempvar As String
Public Sub setvar(strvar As String)
tempvar = strvar
End Sub
Public Function getvar() As String
getvar = tempvar
End Function

in the event open of the report
Private Sub Report_Open(cancel As Integer)
setvar "12345"
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV

when i run the report the event open calls setvar, but what about public function getvar.

i tried and i am still getting the same message.

even if i tried using only sub setvar or function getvar; separate, i get the same error message.
 
The only way to get this is defining a public tempvar in the report module.
but i have like 10 reports thet will use the same tempvar. Does this means that i have to define one public var for each report. I though there was a way to define a public var and use the same var in all reports.

Thanks again
 
No, you shouldn't have to use 10.

How are you using the variable, in the report?
 
Did you use the getVar() function in the report query or on the report.
 
qu'est-ce que c'est, GetVar()?
That's not VBA, is it?
 
qu'est-ce que c'est, GetVar()?
A function I defined in my 1st reply to retrieve the value of the global variable.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
oops, ...and so it is!
I guess that would make it VBA also, LOL!
Thx PHV!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top