Alternative might be to have the function construct the criteria string.
For
instance if looking for 2335 or variations of it, you could use
Like "[2335][2335][2335][2335]"
Using a VBA function to build that string would fairly simple. UNTESTED
AIRCODE follows.
Public Function fBuildSearch(strIn) as String
Dim i as Integer, strOut as String
If IsNull(StrIn) then
fBuildSearch = vbnullstring
Else
For i = 1 to Len(strIN)
strOut = StrOut & "[" & Mid(StrIn,i,1) & "]"
Next i
fBuildSearch = strOut
End if
End Function
So the criteria in the query would be
Where NumberField & "" Like fBuildSearch("2335")
Of course, that all assumes that the field is a string. More complex
would be
searching a number field for number values or optimizing this search for
speed
using indexes.
Tom said:
Dear Natty:
I would like to suggest you write a function that accepts two strings.
One
I'll call the "target string" should contain the "pattern" for which you
are
searching. The other should contain the "subject string" from the table.
This function should return a boolean (true/false) that signifies whether
the subject string matches the combination from the pattern.
Before writing the function, you must determine whether a match occurs
under
certain conditions. Must the subject string contain only characters in
the
target? Must the subject string contail all the characters in the
target?
May the subject string repeat characters in the target only the exact
number
of times they are repeated in the target?
The above questions are exampled below, in the order I asked them:
target subject
12 123
123 12
11 1
1 11
The last two are different ways of looking at my last question.
After you are certain of your answers to these questions, there may be
alternate ways of performing the test.
Are there any characters to be ignored? Is a space in the subject or
target
to be considered in the matching? Or perhaps both are always digits
only.
If none of the above cases is considered a match, then this suggests that
the two strings must be of the exact same length. Then, sorting the
string
by moving the characters in ascending order, the two strings must then
exactly match. Is that what you're after?
Tom Ellison
Microsoft Access MVP
How can I do a query and retrieve numbers from a table in any order?
Example,
input 2345 and retrieve 2435, 5234, and 4352 other combinations not
available.