Forum Discussion
Assigning Criteria Result to a Variable
- Jan 15, 2022
you can try creating a Public function for the Parameter Criteria of your query.
let say your table has a FirstName field and you want to filter it:
global varParam As Variant
public function getQueryParam()
gstrParam = ""
gstrParam = Inputbox("Input the name of person", , varParam)
If IsNumeric(varParam) Then
varParam = Val(varParam)
End IfgetQueryParam = varParam
end function
your Global/Public variable is varParam.
you can try creating a Public function for the Parameter Criteria of your query.
let say your table has a FirstName field and you want to filter it:
global varParam As Variant
public function getQueryParam()
gstrParam = ""
gstrParam = Inputbox("Input the name of person", , varParam)
If IsNumeric(varParam) Then
varParam = Val(varParam)
End If
getQueryParam = varParam
end function
your Global/Public variable is varParam.
- isladogsJan 15, 2022MVPYou could also consider using a tempvar. These can be used directly in a query.
No need for a user defined function- arnel_gpJan 15, 2022Steel Contributori just tested with Tempvars as Criteria, the query runs without any prompt for a Criteria.
- George_HepworthJan 15, 2022Silver Contributor
There is a sample download on my website in which I demonstrate using tempvars as parameters in queries, along with some other uses. I ended up wrapping the tempvars in helper functions, however, for reasons I've forgotten at the moment.