Results 1 to 4 of 4

Thread: partial match query

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    34

    Question

    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

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    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?

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    34

    Question partial match query

    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?

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    34

    partial query success

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width