InStr Function for Access 97

R

Rachel

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

Thanks
 
R

Rick Brandt

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.
 
B

Brian Camire

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".
 
D

Dirk Goldgar

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top