Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Location
    Sheffield, UK
    Posts
    17

    Unanswered: Parameter in SQL query

    I have a search form where the use can enter text and I want to be able to search for records where the entered string is in any part of the field. The SQL is below:

    SELECT tbljobs.autojobid, tbljobs.jobaddy1, tbljobs.jobaddypc, tbljobs.ponumber, (([tblJobs].[totalLabourCosts])+([tblJobs].[partscost]))*1.175 AS Amount
    FROM tbljobs
    WHERE (((tbljobs.jobaddypc) Like " * " & ([Forms]![frmsearch]![txtpc]) Or (tbljobs.jobaddypc) Like ([Forms]![frmsearch]![txtpc]) & " * " Or (tbljobs.jobaddypc)=[Forms]![frmsearch]![txtpc]))
    ORDER BY tbljobs.jobaddypc;

    But it only shows records where there is a complete match on the txtpc(field on the form) and the recrod field. Can anyone tell me what I have written wrongly?


    Thanks

    Wheelz

  2. #2
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    Select *
    from table
    where column LIKE '*'&[param]&'*'
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  3. #3
    Join Date
    Dec 2003
    Location
    Sheffield, UK
    Posts
    17
    Thanks for that.

Posting Permissions

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