InStrRev Function

Applies To
Access for Microsoft 365 Access 2024 Access 2021 Access 2019 Access 2016

Returns the position of one string within another in an Access desktop database. The search starts at the end of the string.

Syntax

InStrRev(stringcheck, stringmatch [, start[, compare]])

InStrRev has these arguments:

Argument Description
stringcheck Required. The string expression to search.
stringmatch Required. The string expression to find.
start Optional. A numeric expression that sets the starting position for each search. If you omit it, -1 is used. This value means the search starts at the last character position. If start contains Null, an error occurs.
compare Optional. A numeric value that indicates the type of comparison to use when evaluating substrings. If you omit it, Access performs a binary comparison. See the Settings section for values.

Settings

compare can use these settings:

Constant Value Description
vbUseCompareOption -1 Performs a comparison by using the setting of the Option Compare statement.
vbBinaryCompare 0 Performs a binary comparison.
vbTextCompare 1 Performs a text comparison.

Return values

If InStrRev returns
stringcheck is zero-length 0
stringcheck is Null Null
stringmatch is zero-length start
stringmatch is Null Null
stringmatch isn't found 0
stringmatch is found within stringcheck The position where the match is found
start > Len(stringmatch) 0

Remarks

The syntax for InStrRev isn't the same as the syntax for InStr.

Query examples

Expression Results
SELECT Names_InstrRev.*, InStrRev(FullName,"S") AS Expr1 FROM [Names_InstrRev]; Returns the position of "S" in the values in the FullName column of the Names_InstrRev table.
SELECT Names_InstrRev.*, InStrRev(FullName,"S",10) AS InStrTest FROM [Names_InstrRev]; Returns the position of "S" in the values in the FullName column of the Names_InstrRev table, starting at position 10, and displays the result in the InStrTest column.

See Also

String functions and how to use them