Results 1 to 3 of 3

Thread: Search Query

  1. #1
    Join Date
    May 2009
    Posts
    104

    Unanswered: Search Query

    Does anyone have any idea why one works and one doesn't.

    This returns all records containing "THREAD"

    SELECT GageList.GageNumber, GageList.GageSize, GageList.GageDescription, GageList.GageClass, GageList.CalibrationDate, GageList.GageStatus, GageList.CurrentLocation, GageList.CalibrationFrequencyYrs, GageList.CalibrationVerificationMethod
    FROM GageList
    WHERE (((GageList.GageDescription) Like "*THREAD*"));

    This returns all record for what the combo box "GageDes" equals.

    SELECT GageList.GageNumber, GageList.GageSize, GageList.GageDescription, GageList.GageClass, GageList.CalibrationDate, GageList.GageStatus, GageList.CurrentLocation, GageList.CalibrationFrequencyYrs, GageList.CalibrationVerificationMethod
    FROM GageList
    WHERE (((GageList.GageDescription)=[Forms]![frmPrintReportByDesc]![GageDesc]));

    This doesnt return any records at all:

    SELECT GageList.GageNumber, GageList.GageSize, GageList.GageDescription, GageList.GageClass, GageList.CalibrationDate, GageList.GageStatus, GageList.CurrentLocation, GageList.CalibrationFrequencyYrs, GageList.CalibrationVerificationMethod
    FROM GageList
    WHERE (((GageList.GageDescription) Like "*Forms![frmPrintReportByDesc]![Combo34]*"));

    The only difference in all 3 statements is the "Like" argument.

    Really all i'm trying to do is us the value entered into the form filter records in a query to drive a report that finds all records containing a value entered into the form. As in this example the operator enters THREAD into the text box in the search form and clicks a button that opens the report so only the records containing THREAD will show up in the report. The top SQL statement from the query in my database works but when i replace "*THREADS*" with "*Forms![frmPrintReportByDesc]![Text23]*" no records are returned.

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Try

    ...Like "*" & [Forms]![frmPrintReportByDesc]![Combo34] & "*"
    Paul

  3. #3
    Join Date
    May 2009
    Posts
    104
    Thats it, works perfectly. Bad thing is i was almost there
    i had

    '*"&[Forms]![frmPrintReportByDesc]![Combo34]&"*'

    This is just something i found in someone elses search macro. I didnt even know i was even in the ballpark. Thanks a bunch Paul.

Posting Permissions

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