Alpha Video Training
Results 1 to 3 of 3

Thread: Can I filter a (one to many) embedded browse

  1. #1
    Member
    Real Name
    Brad Steinfeldt
    Join Date
    Feb 2002
    Location
    Murray, Utah
    Posts
    137

    Default Can I filter a (one to many) embedded browse

    Help anyone,

    I have a set that has customer information, which includes appointments that are linked to the customer in a one to many link (a customer might have many appointments). These appointments are either completed or not (determined by a logical field-- completed). I've created a form that uses an embedded browse to show these appointments. Right now, it shows all of them, but I want to be able to filter out just the completed ones, or the not completed ones, or all of them.
    I've create a dropdown list using action scripting with three choices (all, todo, done) to be used as a filter, but I can't figure out how to filter the records of a child table. There's no way that I've found to filter an embedded (one to many) browse by using action scripting. Can it be done using xbasic? I'm not very good at creating xbasic, but I can usually understand it.
    Here is what I've created so far:

    DIM SHARED Act_sortby AS c 'this is the variable in the dropdown list
    Dim brws as P
    Dim qry as P
    Dim nrecs as N

    'setup things and check

    brws=Customer_Locate:Tables:prospect.Current()

    ' *****if the user selects "todo", it will do this statement*****
    IF a5_eval_expression("=Var->Act_sortby=\"todo\"") THEN
    query.description="To Do Activities"
    query.filter = "flattenquery("+"(Prospect->Completed = .f. )"+")"
    query.order = "cdate(Prospect->Sch_date)+Prospect->Sch_time"
    query.options = ""
    query.description = "Saved Query:To_do_filter"
    nrecs= brws.query.records_get()
    if (nrecs=0) then
    qry.drop()
    ui_msg_box("No Records","There are no To Do Activities for this customer.",UI_INFORMATION_SYMBOL)
    end
    end if
    brws.query_create()
    brws.refresh()
    END IF

    ' If the dropdown1 choice is All records, it will do this statement
    IF a5_eval_expression("=Var->Act_sortby=\"all\"") THEN
    brws.show_all()
    brws.refresh()
    END IF

    ' If the dropdown1 choice is completed records, it will do this statement
    IF a5_eval_expression("=Var->Act_sortby=\"done\"") THEN
    query.filter = "flattenquery("+"(Prospect->Completed = .t. )"+")"
    query.order = "cdate(Prospect->Sch_date)+Prospect->Sch_time"
    query.options = ""
    query.description = "Saved Query:To_do_filter"
    brws.query_create()
    brws.refresh()
    END IF

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

    Default

    Brad, I don't think you can do this using Action Scripting.

    I've prepared an example for you using xbasic scripts. They're not too complex, and I've heavily commented one of them for you. The others follow the same pattern so once you understand the OnPush script for the "Completed" button you'll be able to make sense of the others.

    In my example I've simply filtered the linked one-to-many child table. I have NOT done a cross-level query which would exclude parent table records if they did not have any matching linked child table records. This was your goal, as I understood it. In other words, all that's being filtered are the records in the child table. The range of parent table records that are being displayed through the form is not affected (because the query I use is not cross-level).

    Hope this helps.

    --tom

    p.s. The approach I've taken in the example is patterned after the discussion appearing in the help files in the topic called "Querying and Sorting Child Tables on a Form", which I think is pretty much on point. One could study this for additional details, a second example, and background.
    Last edited by Tom Cone Jr; 12-31-2005 at 05:38 PM.

  3. #3
    Member
    Real Name
    Brad Steinfeldt
    Join Date
    Feb 2002
    Location
    Murray, Utah
    Posts
    137

    Default

    Thanks so much for your direction. I'll look at it.

Similar Threads

  1. filter a (one to many) embedded browse
    By acceptthis in forum Alpha Five Version 6
    Replies: 0
    Last Post: 12-27-2005, 06:41 PM
  2. Filter/Sort Embedded Browse
    By intertag in forum Alpha Five Version 6
    Replies: 13
    Last Post: 03-26-2005, 09:42 PM
  3. Filter in Embedded Browse
    By Herbert in forum Alpha Five Version 5
    Replies: 7
    Last Post: 10-05-2004, 02:14 PM
  4. filter for embedded browse
    By Mark Lucas in forum Alpha Five Version 5
    Replies: 4
    Last Post: 03-27-2004, 03:41 PM
  5. Filter an embedded browse
    By Alan Anthony in forum Alpha Five Version 4
    Replies: 5
    Last Post: 02-21-2001, 09:15 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
  •