Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Like Operater in QueryDef (Access 2000)

    I am trying to set up a parameter query which retireves all users with a cetain name. I have the user enter the last name and first name as the criteria. When I try to run my QueryDef, I never get any results. From what I can see, you cannot have two like clauses in the where clause. How can I get both the last name and first name as parameters in the query. I have the following:

    SELECT Consultants.LastName, Consultants.FirstName, Consultants.StreetAddress, Consultants.Province, Consultants.PostalCode, Consultants.PhoneNumber, Consultants.EmailAddress, Consultants.ConsultantID
    FROM Consultants
    WHERE ((( [Consultants].[FirstName] LIKE [Forms]![FRM_NewHostess]![txtbox_FirstName]) + "*" AND (([Consultants].[LastName] LIKE [Forms]![FRM_NewHostess]![txtbox_LastName])+ "*"))) ;

    Thanks

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

    Re: Like Operater in QueryDef (Access 2000)

    You've got parentheses in the wrong place: they shouldn't be after the parameters, but after the "*".
    Although + doesn't hurt in this case, it's better to use & to concatenate strings instead of +.
    The WHERE part should be

    WHERE ((Consultants.FirstName Like [Forms]![FRM_NewHostess]![txtbox_FirstName] & "*") AND (Consultants.LastName Like [Forms]![FRM_NewHostess]![txtbox_LastName] & "*"))

  3. #3
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Like Operater in QueryDef (Access 2000)

    Nevermind, It was the brackets.

    I need a slurpee

Posting Permissions

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