Using a Query Prompt to Filter Data in a Text File Database |
Searching by using a query prompt is similar to searching by using any other kind of filter. You can use wildcard characters to refine your search. In text file databases, you can escape certain special characters so that they are handled as simple characters in the query prompt filter.
To escape a special character, you add brackets ([ ]) around it to indicate that the character is handled as part of the search term.
For example, suppose that you created the following query prompt for the "Name" field in a text file database:
Name Like ?NamePrompt
At print time, when you enter John*
for the query prompt, any name that starts with "John" is matched. You might get search results such as the following:
John Berry
John Hancock
John Smith
However, if you actually want to find the entry "John*", where the asterisk (*) is part of the search term, you want the asterisk to be treated as a simple character instead of as a wildcard. To do this, escape the asterisk by enclosing it in brackets. At print time, enter John[*]
as the search term for the query prompt. When you do this, only entries that contain "John*" are matched.
If you need to search for a term that contains brackets, such as "MyText[1]", you must escape the first bracket so that it is treated as a simple character. In this case, enter MyText
[
[
]
1]
at print time for the query prompt. (You do not need to escape the second bracket.)
When you use operators, you must use escaping only when you use LIKE
, NOT LIKE
, BEGINS WITH
, NOT BEGINS WITH
, ENDS WITH
, NOT ENDS WITH
, CONTAINS
, and NOT CONTAINS
.
Escaping is not needed, nor will it work, for other operators, such as EQUALS
and NOT EQUALS
.
For more information about how to use filters, refer to Filtering Data.
Related Topics