Alpha DevCon 2018
Results 1 to 5 of 5

Thread: Sub String Search

  1. #1
    Member
    Real Name
    Fred Daniels
    Join Date
    Nov 2017
    Posts
    1

    Default Sub String Search

    It has been many years since I did this. I'm trying to create a button to do a search on a field where the user can search by entering a few letters and find all records that contain those letters. Did it a long time ago and forgot how.

  2. #2
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,407

    Default Re: Sub String Search

    Hi Fred,
    Happy Thanksgiving and welcome to the board!

    Have you looked at the Customer form example in AlphaSports using dropdown controls?

    An alternative is to define a variable for your form (I call mine 'SearchFor') then add a type-in field using this variable on the form. The form will need to be ordered by the field you want to search. If this is always the same you can set that field in the form properties. Otherwise you can add another variable for a combo box with a list of the fields the user might want to search by (I call mine - you guessed 'Searchby'). The OnChange event of this variable will set the index the form uses. Then the OnDepart event for the SearchFor field can run a topparent.find(var->searchfor) to locate your record.

    Let me know if you need an example.
    Last edited by MoGrace; 11-23-2017 at 11:43 AM. Reason: corrected controls to use
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  3. #3
    Member
    Real Name
    Mark Bierer
    Join Date
    May 2012
    Location
    Tucson, AZ
    Posts
    43

    Default Re: Sub String Search

    I would appreciate and example of that.

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,011

    Default Re: Sub String Search

    If you truly mean "find all records that contain those" rather than "find all records that begin with those" then you need to query for search_string $ field_name.

    On the AlphaSports customer information form you could have a button

    Code:
    search_for = ui_get_text("Search","Enter characters to be found"+crlf()+"anywhere in the last name field.","abc")
    
    if alltrim(search_for) > ""
    	tbl = table.current()
    	tbl.query_create("N",quote(search_for)+" $ lastname","lastname")
    	parentform.Resynch()
    end if
    There can be only one.

  5. #5
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,127

    Default Re: Sub String Search

    Hi Fred,
    I attached an example that might be what you are looking for. It searches customers with a progressive lookup that starts with two characters typed into the find text field. Hope this helps.
    Attached Files Attached Files
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

Similar Threads

  1. Approximate String Matching - Fuzzy Search
    By mikew in forum Application Server Version 10 - Web/Browser Applications
    Replies: 2
    Last Post: 02-01-2011, 05:37 AM
  2. search & remove a comma from a string
    By davidab in forum Alpha Five Version 8
    Replies: 7
    Last Post: 10-29-2008, 06:53 AM
  3. Replies: 13
    Last Post: 10-02-2007, 06:46 PM
  4. Highlighting Search String in Grid Search
    By acidcigarfiend in forum Web Application Server v7
    Replies: 16
    Last Post: 03-03-2006, 12:12 AM
  5. Search Field for string
    By CapeMayAl in forum Alpha Five Version 5
    Replies: 0
    Last Post: 08-09-2004, 11:21 AM

Bookmarks

Posting Permissions

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