Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2006
    Posts
    26

    Question Unanswered: Searching by Like Address

    I'm using MSAccess 2007 and trying search by address and got stomped and help would be appreciated.

    Criteria:
    1. form contains unbound text box to search
    2. search and display all records containing (LIKE) the search text
    3. double click to open that record

    What I want to do is search the address that may contain the search text anywhere in the address, then list all matching ones so I can double click on one to open.

    Combo box and lists will search the beginning of the address. I've also tried using subform but can't get it to work with SQL.

    My latest attempt blow returns nothing:
    unbound searchText in form header
    unbound continuous form in detail
    on search:
    sSQL = "SELECT * FROM tbl_Units WHERE Address LIKE '%" & Me.txtSearch & "%'"
    Me.RecordSource = sSQL
    Me.Requery

    I've been working on this problem for days, and I'm ready to give up. Thanks.
    Last edited by itchibahn; 04-01-12 at 02:48.
    We're just a speck of dust in a universe.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Except in the case of a pass-through query, the wildcard character in Access is '*', not '%'. try using:
    Code:
    sSQL = "SELECT * FROM tbl_Units WHERE Address LIKE '*" & Me.txtSearch & "*'"
    Have a nice day!

  3. #3
    Join Date
    Feb 2006
    Posts
    26
    That worked, thanks...
    We're just a speck of dust in a universe.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Tags for this Thread

Posting Permissions

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