using a public Variable in a query

N

NNlogistics

I set up a variable(intRMAExceptions) in a module and want to use as the
criteria in a query. I think the variable setup is ok because I can print it
in a text box. I put it in brakets [intRMAExceptions]. Could the problem be
in the format I am using/
Thanks for any assistance
 
K

Klatuu

I recommend it be a Static function. You can make it work like a variable.
If you pass it a value, it takes on the new value. If you call it, it
returns the current value Just assign it the data types you need. I will use
Variant as an example. In fact, U useually make mine Variant so they will
handle Null without a problem:

Static Function GetRMAExceptions(Optional varNewValue as Variant) As Variant
varSaveValue as Variant

If Not IsMissing(varNewValue) Then
varSaveValue = varNewValue
End If
GetRMAExceptions = varSaveValue
End Function

Rick Brandt said:
NNlogistics said:
I set up a variable(intRMAExceptions) in a module and want to use as
the criteria in a query. I think the variable setup is ok because I
can print it in a text box. I put it in brakets [intRMAExceptions].
Could the problem be in the format I am using/
Thanks for any assistance

Variables are not available to queries, but user defined functions are.
Build a function that does nothing but return the value of your variable and
then use the function in your query.
 
Top