What is a wildcard character in Access?

What is a wildcard character in Access?

            Wildcard characters in Access add flexibility to query criteria. Wildcard characters in Access represent unknown values. The asterisk “*” and the question mark “?” are the two main wildcard characters in Access you need to know. The asterisk represents multiple unknown characters. For example, the criteria “N*” would find all “N” words like “Nebraska,” “Ned,” “Not,” “Never Ever,” etc.

            The question mark represents one unknown character. So using a criteria like “N?D” would only find three letter “N…D” words like “Ned” and “Nod.” You can type as many question marks as needed to fill-in the required unknown characters. So, typing “N??D” finds words like “Need” and “Nerd,” for example.

What is a wildcard character in Access?

A picture showing how to use wildcard characters within query criteria in Access.

            When you type wildcard characters into the criteria row of the QBE grid, Access adds the word “Like” before them when you exit the criteria cell. This is simply the required syntax. It isn’t necessary for you to type it yourself, if you don’t want to, as Access adds it for you when it notices the wildcard characters being used. However, don’t worry if it appears in your wildcard criteria, either.

            To use wildcard characters in query criteria in Access, open the desired query in query design view. Then click into the “Criteria” row underneath the field into which to add the criteria. Type the criteria for which to search, using the appropriate wildcard characters. Finally, click the “Save” button in the Quick Access toolbar to save your changes.

Instructions on How to Use Wildcard Characters in Access Queries

  1. To use wildcard characters in Access queries, open the desired query in query design view.
  2. Then click into the “Criteria” row underneath the field into which to add the criteria.
  3. Type the criteria for which to search, using the appropriate wildcard characters:
    ? = a single unknown character.
    * = multiple unknown characters.
  4. Finally, click the “Save” button in the Quick Access toolbar to save your changes.

Video Lesson About Using Wildcard Characters in Access

            The following video lesson, titled “Using Wildcard Characters in Queries,” shows how to use wildcard characters in Access query criteria. This video is from our complete Access tutorial, titled “Mastering Access Made Easy v.2019 and 365.”

To locate a specific item when you can't remember exactly how it is spelled, try using a wildcard character in a query.

Wildcards are special characters that can stand in for unknown characters in a text value and are handy for locating multiple items with similar, but not identical data. Wildcards can also help with getting data based on a specified pattern match. For example, finding everyone named John on Park Street.

For more information about queries, see introduction to queries.

Here are some examples of wildcard characters for Access queries:

Character

Description

Example

*

Matches any number of characters. You can use the asterisk (*) anywhere in a character string.

wh* finds what, white, and why, but not awhile or watch.

?

Matches a single alphabet in a specific position.

b?ll finds ball, bell, and bill.

[ ]

Matches characters within the brackets.

b[ae]ll finds ball and bell, but not bill.

!

Excludes characters inside the brackets.

b[!ae]ll finds bill and bull, but not ball or bell.

Like “[!a]*” finds all items that do not begin with the letter a.

-

Matches a range of characters. Remember to specify the characters in ascending order (A to Z, not Z to A).

b[a-c]d finds bad, bbd, and bcd.

#

Matches any single numeric character.

1#3 finds 103, 113, and 123.

Learn more about applying criteria to a query.

To use a wildcard character within a pattern:

  1. Open your query in Design view.

  2. In the Criteria row of the field that you want to use, type the operator Like in front of your criteria.

  3. Replace one or more characters in the criteria with a wildcard character. For example, Like R?308021 returns RA308021, RB308021, and so on.

  4. On the Design tab, click Run.

Here are some examples of wildcard patterns that you can use in expressions:

C haracter(s)

Use to match

? or _ (underscore)

Any single character

* or %

Zero or more characters

#

Any single digit (0 — 9)

[charlist]

Any single character in charlist

[!charlist]

Any single character not in charlist

[a-zA-Z0-9].

Any alphanumeric character

[A-Z]

Any of the uppercase letters in the range A through Z.

Note:  When you specify a range of characters, the characters must appear in ascending sort. For example, [Z-A] is not a valid pattern.


Take a look at the basics of building an expression.

To match special characters like question mark (?), number sign (#), and asterisk (*), put them in square brackets.

The CHARLIST function gives you matches for one or more characters and can include almost any characters in the ANSI character set, including digits. The CHARLIST is enclosed in brackets ([ ]) and can be used with wildcard characters for more specific matches.

To specify a range of characters, use CHARLIST with a hyphen (-) to separate the upper and lower bounds of the range.

To match the hyphen (-) character, put it at the beginning or end of CHARLIST (after the exclamation mark if you’re using one). In any other location, the hyphen identifies a range of ANSI characters.