Open ended search/how to create the query;

Results 1 to 2 of 2

Thread: Open ended search/how to create the query;

  1. #1
    Nathan B. Guest

    Default Open ended search/how to create the query;

    I&#039m using MS ACCESS and have a situation to which I can&#039t figure out an efficient solution.<BR><BR>First off; I&#039m accepting a string which will contain keywords from which I&#039ll generate a list of matching records from the database.<BR><BR>An example of my string parsing; <BR> [Search for]: 957, a2932, Console Switch<BR><BR>"957, a2932, Console Switch" will be extracted into four strings containing:<BR>"957"<BR>"a2932"<BR>"Console"<BR>"S witch"<BR><BR>I was intending to do this search by creating a parameter object for each, appending and suffixing with *:<BR>"*957*"<BR>"*a2932*"<BR>"*Console*"<BR>"*Swi tch*"<BR><BR> that a search will by default cover a "Begins with.." "Contains.." or "Ends with.." type query.<BR><BR>My situation comes in that I do not know how to effectively execute each of these queries, prevent duplicate entries, and insure the same record order each time the search takes place.<BR><BR>Any clues on how to do a stored query, allow an open ended number of " or MODEL_NUM like [blahblah] " ?<BR><BR>Thanks.<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Open ended search/how to create the query;

    You could put your search strings in an array and the build you where cluase based on the array ...<BR><BR>&#060;%<BR>aKeywords = Array("957", "a2932", "Console", "Switch")<BR><BR>for i = 0 to ubound(aKeywords)<BR>if Len(sWhere) then<BR>sWhere = sWhere & " OR MODEL_NUM LIKE &#039*" & aKeywords(i) & "*&#039"<BR>else<BR>sWhere = sWhere & " MODEL_NUM LIKE &#039*" & aKeywords(i) & "*&#039"<BR>end if<BR>Next<BR>sSql = sSql & sWhere<BR><BR>%&#062;<BR><BR>

Posting Permissions

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