Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    Posts
    9

    Question Unanswered: Like Function Help!!!

    In the criteria of a query I want to use the Like function to act like somewhat of a search tool.

    Table (STAT List): One field with all unique records, STAT.
    Form (STAT Form): I have a textbox in which the user can enter a STAT or letters of a STAT and find any that match.
    Query: Querying the STAT field where the criteria uses the Like function.

    Current Criteria: IIf([Forms]![STAT Form]![STAT] Is Null,[STAT List]![STAT], Like "*[Forms]![STAT Form]![STAT]*")

    Basically I want it to check if the field is null, if so then it returns all the STATs. This works fine. Now, if the textbox is NOT null I want the value that has been entered to be put into the Like function with the "* *" surrounding it so it will look for anything containing the entry.

    Aside from using VB, is there some sort of syntax I can use to get this to work? I hope I've explained this well enough. Thanks in advance for the help.

    cj

  2. #2
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238

    Re: Like Function Help!!!

    Originally posted by cjwang80
    In the criteria of a query I want to use the Like function to act like somewhat of a search tool.

    Table (STAT List): One field with all unique records, STAT.
    Form (STAT Form): I have a textbox in which the user can enter a STAT or letters of a STAT and find any that match.
    Query: Querying the STAT field where the criteria uses the Like function.

    Current Criteria: IIf([Forms]![STAT Form]![STAT] Is Null,[STAT List]![STAT], Like "*[Forms]![STAT Form]![STAT]*")

    Basically I want it to check if the field is null, if so then it returns all the STATs. This works fine. Now, if the textbox is NOT null I want the value that has been entered to be put into the Like function with the "* *" surrounding it so it will look for anything containing the entry.

    Aside from using VB, is there some sort of syntax I can use to get this to work? I hope I've explained this well enough. Thanks in advance for the help.

    cj
    Try this...
    Current Criteria: IIf([Forms]![STAT Form]![STAT] Is Null,[STAT List]![STAT], Like "*" & [Forms]![STAT Form]![STAT] & "*")

    HTH

Posting Permissions

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