Check RS value against multiple

I am attempting to evaluate a value returned in recordset and take an action based on the value in that record, in this particular case add a color.

Is there a way to evaluate a recordset value against multiple options in the same line? I tried the following code but it is erroring out.

IF (rs.IdxField(9).StringValue) in ("PICKUP","GRAPHICS","HOLD PARTS","HOLD VEHICLE") then lstWO.RowTag(lstWO.LastIndex) = "Red"

Thanks as always from the new guy.

I think that the best approach here, and a good learning exercise, is to create a class extension that extends the string class.

Create a module in your project (the name of the module doesn’t matter, but I tend to favor ‘ClassExtensions’) and create a global method in that module:

Public Function InValues(extends aString as String, ParamArray values as String) as Boolean return values.IndexOf(aString) <> -1 End Function

Now you can use it similar to your original code:

if rs.IdxField(9).StringValue.InValues("PICKUP","GRAPHICS","HOLD PARTS","HOLD VEHICLE") then // Do something end

Or use InStr

IF  InStr("PICKUP,GRAPHICS,HOLD PARTS,HOLD VEHICLE", rs.IdxField(9).StringValue) > 0  then

Any reason you can’t apply that to the WHERE statement in the original SQL?

[quote=383620:@Tim Hare]Or use InStr

IF InStr("PICKUP,GRAPHICS,HOLD PARTS,HOLD VEHICLE", rs.IdxField(9).StringValue) > 0 then [/quote]
one hole in that… “PICK” “ART”, “OLD” all return a >0 value

Thanks for all the replies. I knew there had to be a way to build a better mousetrap.

I am using the value of field to set a RowTag which is used to change the background color of the row depending on what choice is made.