PDA

Click to See Complete Forum and Search --> : partial match query


damarious
Sep 8th, 2000, 02:52 PM
I'm trying to search a table with the following data format:
#.#.#.#/#, #.#.#.#/#, #.#.#.#/#, #.#.#.#/#

I want to check to see if a string (#.#.#.#/#) exists anywhere in the table. I've got a .FindFirst query (posted below) that won't return a match. Maybe my approach is wrong.

Set db = CurrentDb
Set rs = db.OpenRecordset("MainData", dbOpenDynaset)

strSrch = "IP like '" & currentEntry & "'"

With rs
.MoveFirst
.FindFirst strSrch
If .NoMatch Then
MsgBox "NOMATCH"
Else
MsgBox "MATCH!"
End If
End With

DrewDog_21
Sep 8th, 2000, 04:45 PM
to the best of my knowledge (someone correct me if I am wrong), you can only use the LIKE operator with strings, and you have to include the * or whatever wildcard character your SQL uses. For Jet, it would be LIKE '" & currentEntry & "*'

it doesn't appear that your fields are strings, though. What are they, dates? numbers?

damarious
Sep 8th, 2000, 05:04 PM
Actually, they are all strings. I have to have them that way to manipulate them later. I have to search through a cell containing this data:

12.3.54.63/12, 43.23.34.54/9, 234.45.23.5/14, 12.12.45.6/24

and have it tell me if 43.23.34.54/9 is there or not.
For some reason, the .FindFirst doesn't like the wildcards. If there another way I should do this? Or is my code off?

damarious
Sep 8th, 2000, 05:14 PM
I got it! Thanks. I tried a slight modification of what I had been doing with the wildcards and changed wildcards to the Jet version (Had been using SQL.... darrr...)

Right!