Crystal Reports – How to test if string contains

The following formula shows how to test if a text field contains particular text.

For example:

Value Formula Result
a quick brown fox InStr( {value}, ‘red’ ) false
a quick brown fox InStr( {value}, ‘brown’ ) true

Note: the InStr function is case sensitive – if you want to test case insensitive you need to convert the value to lowercase first. For example

InStr( lcase( {value} ), 'brown' ) > 0

Reference: http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=2409

Related Articles

Leave a Reply

Your email address will not be published.