THE WORLD'S LARGEST WEB DEVELOPER SITE

MS Access InStr() Function

❮ MS Access Functions

Example

Search for "t" in string "Customer", and return position:

SELECT InStr("Customer", "t") AS MatchPosition;
Try it Yourself »

Definition and Usage

The InStr() function returns the position of the first occurrence of a string in another string.

Syntax

InStr(start, string1, string2, compare)

Parameter Values

Parameter Description
start Optional. The starting position for the search. Position 1 is default
string1 Required. The string that will be searched
string2 Required. The string to search for
compare Optional. The type of comparison to perform.

Possible values:
-1: Uses option compare
0: Binary comparison
1: Textual comparison
2: Comparison based on your database

Note

  • InStr() performs a case-insensitive search
  • If string2 is not found within string1, the InStr() function will return 0
  • If string1 is zero-length, the InStr() function will return 0
  • If string1 is null, the InStr() function will return null
  • If string2 is zero-length, the InStr() function will return the value used in the start parameter
  • If start is greater than string2, the InStr() function will return 0

Technical Details

Works in: Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000

❮ MS Access Functions