Skip to main content

using a Variable in the Task.Criteria

Hey,
 
I am currently working on a searching filter function so I can filter a database. For this function I have a String variable as input. Somehow Idea doesn't allow me to use the Variable in this function and I just cant Figure out why.
 
Function SearchFilter(KeyWord As String)
 
task.Criteria = "@Isini(KeyWord; Column1) .OR. @Isin(KeyWord; Column2) .OR. @Isini(KeyWord; Column3) .OR. @Isini(KeyWord; Column4)"
 
When I run the script, all goes well until te part where I enter the variable. Then IDEA gives me a error message : "The paramater is incorrect". When I MsgBox KeyWord, the variable shows exactly how I want it to be and how I want to use it to filter the database.  I think my problem is in the accolades but after an hour of trying and erroring I just don't know what to anymore.
 
Please help!
 
With kind regards
IGUnique
 
 

Brian Element Tue, 09/18/2018 - 16:36

Hi IGunique,

The problem is that your variable KeyWord is between the double quotes of the equation.  When you do this what it ends up looking for is the actual word KeyWord plus you will get an error because KeyWord should be between double quotes.  What you have to do to access the variable KeyWord is to close your quotes so that the variable can be accessed by the script instead of the script thinking it is part of the criteria.  The script will then substitue what is contained in the variable within the criteria.  You will also need to add on the double quotes.  This is my update of your criteria:

task.Criteria = "@Isini(""" & KeyWord & """; Column1) .OR. @Isin(""" & KeyWord & """; Column2) .OR. @Isini(""" & KeyWord & """; Column3) .OR. @Isini(""" & KeyWord & """; Column4)"

You can see I add two double quote that insert an actual quote in the criteria, I think have a third quote to close of that section, I use the appersand to get access to what is contained within the variable.  Try doing a msgbox before and after of just your criteria, it should help you understand the difference.

Brian