Jimmer: you need to build a from/to range parms to pass to the STRQMQRY — you’ll need a CL pgm to do this. The FROM field value will be what the user keyed in and the TO field value will be the what the user keyed in with “9999”s being concatenated to the end of the TO field value. HTH
It’s more complex because you’re using the long obsolete Query/400 instead of simply using a QM query directly, but I <i>think</i> the overall problem is the same. Here’s your spec:<pre>FIELDLASTNAME EQ :FIELDLASTNAME</pre>A QM query SELECT statement that does the same thing would be:<pre>FIELDLASTNAME = &FIELDLASTNAME</pre>If a user typed this for input:<pre>SM%</pre>…the resulting clause would be:<pre>FIELDLASTNAME = SM%</pre>Unfortunately, that’s not valid syntax. There are no quotes around the literal, so SQL can’t recognize that it’s supposed to be a literal. SQL has no way to know that you didn’t want to check against something named SM and mistakenly typed a ‘%’ in the wrong position.
If you want it to work, you need the clause to end up looking this way:<pre>FIELDLASTNAME = ‘SM%'</pre>That is, either you must put the quotes in the query or the users must type the quotes around the characters.
Take your pick. One way or the other, the query requires quotes.
You can’t put the quotes directly in the SELECT statement. If you do, then the query can’t recognize that there’s a substitution variable in there. The query will treat the quotes as if they’re surrounding a literal.
So, the quotes have to be inserted some other way. Most often, programmers will take the input from the user and put quotes around the value in program code. Since you’re using Query/400, that might be your only choice.
If you’d dump Query/400, it could be easier.