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:
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
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
Comment