Alpha Video Training
Results 1 to 7 of 7

Thread: Another way to find a record, besides tbl.fetch_find?

  1. #1
    Member
    Real Name
    George Furnell
    Join Date
    Apr 2006
    Location
    South Africa
    Posts
    384

    Default Another way to find a record, besides tbl.fetch_find?

    Good day,

    Question:
    I know that I can use tbl.fetch_find in a xbasic UDF to find a record when I know the value of a field(s), but I was wondering if there is another way to find a record.

    Background:
    I want to test if a record exist that contains tbl.firstname = “firstname” and tbl.lastname = “lastname”. And currently I’m using rec = tbl.fetch_find(firtname +lastname) but that does not correctly check for the existence of this combination.

    Kind regards
    George

  2. #2
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: Another way to find a record, besides tbl.fetch_find?

    George, I'd use the key_exist() function after first defining an indextag based on the concatenated string values of the two fields. i.e. firstname + lastname. If the concatenated string value already exists in the list of keys in the index the function will return "True", and you'll know that a record with those field values is present. Otherwise it returns "False".

    -- tom

    ps. your existing approach will also work but again you need to define a compound key and then pass a search term that matches the indextag expression. If you're having trouble it's because either the index is not defined correctly, or you're passing an argument to the function that doesn't match the indextag expression. Trailing blank spaces in table fields can often cause mismatches that are not obvious. In any case, I don't favor doing it this way however because you're opening new instances of both the table and the index. Key_Exist() just opens the index.

  3. #3
    Member
    Real Name
    Jim Coltz
    Join Date
    Oct 2005
    Location
    Western Pennsylvania
    Posts
    600

    Default Re: Another way to find a record, besides tbl.fetch_find?

    A5_GET_RECORDS_IN_QUERY() is very flexible and easy to use for checking for the existence of records that match an expression.

  4. #4
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,937

    Default Re: Another way to find a record, besides tbl.fetch_find?

    And possibly another way is to use lookup() which takes a filter and your table doesn't have to be opened.
    http://support.alphasoftware.com/alp...s/LOOKUP().htm

    or even lookupc() if you have an index name to use so is very similar to Tom's approach.

    These actually return a field's value but all depends on what you need.
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  5. #5
    Member
    Real Name
    George Furnell
    Join Date
    Apr 2006
    Location
    South Africa
    Posts
    384

    Default Re: Another way to find a record, besides tbl.fetch_find?

    Hmm, my initial post was not that clear. So I need to add that after determining wheter first & lastname exist in the table, I need to get something back that will allow me to update the record IF it exists.

    Looking forward to your response.

    Regards
    George

  6. #6
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: Another way to find a record, besides tbl.fetch_find?

    George, if your design is using the combination of firstname + lastname to find records then I'd recommend you create a new index and use an expression to define the index key as the string of characters you get when you concatenate the two fields. You should give some thought to how you're going to arrange for the user to tell you which first and last names to search for. The input strings they supply will have to be massaged to match the structure of the expression you use in the index you define. Remember to take the trailing blanks into consideration. The new index can then be used with the fetch_find() method of the table. If this isn't making sense to you let us know. We can cobble together an example for you, just tell us how you're going to get the names from the user. Even better supply us with a working copy of your form with supporting tables.

  7. #7
    Member
    Real Name
    George Furnell
    Join Date
    Apr 2006
    Location
    South Africa
    Posts
    384

    Default Re: Another way to find a record, besides tbl.fetch_find?

    Good point Tom,

    I was trying the "index" method etc, but because I was not getting it to work, I started looking for alternatives. I will gather my facts and post it here, for asistence from people like yourself.

    Kind regards
    George

Similar Threads

  1. <tbl>.fetch_find() - Conflicting expression Data types
    By aschone in forum Alpha Five Version 8
    Replies: 4
    Last Post: 06-05-2007, 05:55 PM
  2. <tbl>.fetch_find() and goto()
    By dik_coleman in forum Alpha Five Version 7
    Replies: 2
    Last Post: 03-24-2006, 01:43 PM
  3. tbl.fetch_find()
    By Zod Mansour in forum Alpha Five Version 6
    Replies: 2
    Last Post: 11-01-2004, 08:10 AM
  4. tbl.fetch_find()
    By Zod Mansour in forum Alpha Five Version 6
    Replies: 3
    Last Post: 10-20-2004, 01:24 PM
  5. WANTED tbl.fetch_find() failure marker
    By Greg Fong in forum Alpha Five Version 4
    Replies: 2
    Last Post: 03-03-2002, 10:03 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
  •