Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Like expression in query (2000 & XP)

    As an expression in a query to limit the data the query displays, I am trying to use a Like expression along with the contents of an open form field. For example: Like [Forms]![frmRegistration]![txtLastName]. I want the user to only have to enter the first four characters of the last name. If the entire last name is typed in the form field, the query shows records that match what is typed just as it would if the expression did not contain the word like. I tried placing an asterisk at the end but then I get a message that I have not used the correct syntax. I also tried placing quotes around the expression and although I didn't get an error, I did not get any data displayed. What am I doing wrong?
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Like expression in query (2000 & XP)

    You must concatenate the value of the text box with an asterisk as follows:

    Like [Forms]![frmRegistration]![txtLastName] & "*"

    The first part must not be put between quotes (if you did, it would be interpreted as literal text), the second part must be enclosed in quotes; the & character concatenates the two parts.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Like expression in query (2000 & XP)

    That worked like a charm. Thanks so much. The trick is in knowing where to place the quotes.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

Posting Permissions

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