Instr and wildcard

davesmith202

Employee of Access World
Local time
Today, 02:41
Joined
Jul 20, 2001
Messages
522
Is it possible to have something like this:

instr(MyString,"FirstCharacters*LastCharacters")

i.e. using a wildcard such as *
 
I can guess at what you are trying to do, but perhaps you can iterate it for us all.

Perhaps you can use the Like operator.

Instr will look for the instances of the string you have in the second part of the statement. You can compound them to find the instance of the first and then check the instance of the second. Something like ...


instr(MyString,"FirstCharacters") AND instr(Mid(instr(MyString,"FirstCharacters")),"LastCharacters")

Separating them might allow you to check to see if they are within the same word:
FirstPos = instr(MyString,"FirstCharacters")
SecondPos = instr(Mid(instr(MyString,"FirstCharacters")),"LastCharacters")
DifWord = instr(mid(MyString,FirstPos,SecondPos), " ")

If DifWord = 0 AND FirstPos <> 0 AND SecondPos <> 0 Then
MsgBox "They occur in the same word ..."

FYI, I just threw this code together so check it.
 
Last edited:
there is a pattern function built into access
 

Users who are viewing this thread

Back
Top Bottom