This MSAccess tutorial explains how to use the Access Instr function with syntax and examples.
The Microsoft Access Instr function returns the position of the first occurrence of a string in another string.
The syntax for the Instr function in MS Access is:
Instr ( [start], string_being_searched, string2, [compare] )
Optional. This is the type of comparison to perform. The valid choices are:
|vbUseCompareOption||-1||Uses option compare|
|vbDatabaseCompare||2||Comparison based on your database|
The Instr function can be used in the following versions of Microsoft Access:
Let's look at how to use the Instr function in MS Access:
Instr (1, "Tech on the Net", "the") Result: 9 Instr ("Tech on the Net", "the") Result: 9 Instr (10, "Tech on the Net", "t") Result: 15
The Instr function can be used in VBA code in Microsoft Access.
Dim LPosition As Integer LPosition = Instr (10, "Tech on the Net", "t")
In this example, the variable called LPosition would now contain the value 15.
You can also use the Instr function in a query in Microsoft Access.
In this query, we have used the Instr function as follows:
This query will return the position of the first "t" in the CategoryName field. The results will be displayed in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.
The results would now be displayed in a column called Position.
(scroll to see more)