InStr Function for Access 97

  • Thread starter Thread starter Rachel
  • Start date Start date
R

Rachel

Has anyone written a function that will determine whether
a specific word is contained within a text string.

Thanks
 
Rachel said:
Has anyone written a function that will determine whether
a specific word is contained within a text string.

Yeah. Microsoft did :-) InStr() is a built-in function in Access 97.
 
Access 97 does have a built-in InStr function.

However, if you're doing this in a query, might be easier to use the Like
operator.

For example:

SELECT
[Your Table].*
FROM
[Your Table]
WHERE
[Your Table].[Your Field] Like "*some text*"

will return all records from "Your Table" where "Your Field" contains the
text "some text". Check the help for more information.

However, Like is not case-sensitive -- for that you can use InStr with
vbBinaryCompare (which has a value of 0) as the last argument, as in
something like:

SELECT
[Your Table].*
FROM
[Your Table]
WHERE
InStr(1, [Your Table].[Your Field], "some text", 0) <> 0

Neither Like nor InStr "understand" word boundaries. For example, both of
the above queries will return a record if "Your Field" contains the value
"Worrisome textual comparison".
 
Brian Camire said:
Neither Like nor InStr "understand" word boundaries. For example,
both of the above queries will return a record if "Your Field"
contains the value "Worrisome textual comparison".

<lol> *Great* example, Brian!
 
Back
Top