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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

global variable pass to a report's filter

Status
Not open for further replies.

joshuaguilty

Programmer
Apr 26, 2005
81
CA
I have tested the filter is working if I restrict to a field with a value (field1 = 1) and it works.
Now I would like to play with a public variable like (field1 = variable1). I have tried it but got the pop-up window for the "variable1" although it has value to be accepted.
Any idea. Thanks.
 
Use a form or open the report with a Where statement (docmd.openreport).
 
You need a public function that simply returns the value of your public variable. Then make a call to your function in your query.

In your code module, you have the public variable declaration and your function...

Code:
Global gMyVariable as String

Public Function GetMyVariable() as String
   GetMyVariable = gMyVariable
End Function

Then use a call to the function in your query.
 
Thank you for the prompt response.
My global variable's value comes from a loop and I test it with "msgbox" for its functioning. And it is working.
The thing is there seems to be NO connection between the field1 = variable1. I am new to this VBA programming and thank you for the patience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top