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
Act_sortby = topparent:Dropdown1.text
' if the user selects "todo", it will do this statement
IF a5_eval_expression("=Var->Act_sortby=\"todo\"") THEN
' activities_browse is the embedded browse and Prospect is the child table
' I took this stuff from a a filter on the Prospect table when it was a parent
' I know it's missing stuff, or maybe it can't even be done this way
activities_browse.query.filter = "flattenquery("+"(Prospect->Completed = .f. )"+")"
activities_browse.query.order = "cdate(Prospect->Sch_date)+Prospect->Sch_time"
activities_browse.query.options = ""
activities_browse.query.description = "Saved Query:To_do_filter"
activities_browse.query_create()
activities_browse.refresh()
END IF
' If the dropdown1 choice is All records, it will do this statement
IF a5_eval_expression("=Var->Act_sortby=\"all\"") THEN
activities_browse.show_all()
activities_browse.refresh()
END IF
' If the dropdown1 choice is completed records, it will do this statement
IF a5_eval_expression("=Var->Act_sortby=\"done\"") THEN
activities_browse.query.filter = "flattenquery("+"(Prospect->Completed = .t. )"+")"
activities_browse.query.order = "cdate(Prospect->Sch_date)+Prospect->Sch_time"
activities_browse.query.options = ""
activities_browse.query.description = "Saved Query:To_do_filter"
activities_browse.query_create()
activities_browse.refresh()
END IF
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
Act_sortby = topparent:Dropdown1.text
' if the user selects "todo", it will do this statement
IF a5_eval_expression("=Var->Act_sortby=\"todo\"") THEN
' activities_browse is the embedded browse and Prospect is the child table
' I took this stuff from a a filter on the Prospect table when it was a parent
' I know it's missing stuff, or maybe it can't even be done this way
activities_browse.query.filter = "flattenquery("+"(Prospect->Completed = .f. )"+")"
activities_browse.query.order = "cdate(Prospect->Sch_date)+Prospect->Sch_time"
activities_browse.query.options = ""
activities_browse.query.description = "Saved Query:To_do_filter"
activities_browse.query_create()
activities_browse.refresh()
END IF
' If the dropdown1 choice is All records, it will do this statement
IF a5_eval_expression("=Var->Act_sortby=\"all\"") THEN
activities_browse.show_all()
activities_browse.refresh()
END IF
' If the dropdown1 choice is completed records, it will do this statement
IF a5_eval_expression("=Var->Act_sortby=\"done\"") THEN
activities_browse.query.filter = "flattenquery("+"(Prospect->Completed = .t. )"+")"
activities_browse.query.order = "cdate(Prospect->Sch_date)+Prospect->Sch_time"
activities_browse.query.options = ""
activities_browse.query.description = "Saved Query:To_do_filter"
activities_browse.query_create()
activities_browse.refresh()
END IF