Relating to my earlier post...
I'm trying to use tbl.summarize() to get a table that has summary of some fields; it works well when applied to the whole table, but I am trying to get a summary of a filtered table. Here is the code I'm using:
problem is, the tbl.summarize still gives me a summary of the whole table, not of the filtered data. How do I filter the data I send to this function?
I'm trying to use tbl.summarize() to get a table that has summary of some fields; it works well when applied to the whole table, but I am trying to get a summary of a filtered table. Here is the code I'm using:
summarize_db_name = filename_decode("custSummary.DBF")
dim tbl as p
tbl = table.open("shipping")
filter = "PU_week =var->varWeek"
query.filter = replace_parameters(filter,local_variables())
query.order = ""
qry = tbl.query_create()
ON ERROR GOTO ERROR3011200714052484
sum.db = summarize_db_name
sum.db_dd_delete = .F.
sum.result_overwrite = .F.
sum.order = "CUSTOMER"
sum.filter = ""
sum.options = "I"
sum.fields = 8
sum.field1 = "Customer"
sum.code1 = 0
sum.field2 = "Customer"
sum.code2 = 2
sum.field3 = "Truck_Cost"
sum.code3 = 1
sum.field4 = "SELL_PRICE"
sum.code4 = 1
sum.field5 = "MARGIN"
sum.code5 = 1
sum.field6 = "MARGIN"
sum.code6 = 5
sum.field7 = "TOTAL_PCS"
sum.code7 = 1
sum.field8 = "TOTAL_WEIGHT"
sum.code8 = 1
tbl.summarize()
GOTO CONTINUE3011200714052484
ERROR3011200714052484:
ON ERROR GOTO 0
ui_msg_box("Error","Error running Summarize Operation"+crlf()+error_text_get())
END
CONTINUE3011200714052484:
tbl.close()
'Add the table just created by the Summarize operation to the Database..
file_add_to_db(summarize_db_name)
dim tbl as p
tbl = table.open("shipping")
filter = "PU_week =var->varWeek"
query.filter = replace_parameters(filter,local_variables())
query.order = ""
qry = tbl.query_create()
ON ERROR GOTO ERROR3011200714052484
sum.db = summarize_db_name
sum.db_dd_delete = .F.
sum.result_overwrite = .F.
sum.order = "CUSTOMER"
sum.filter = ""
sum.options = "I"
sum.fields = 8
sum.field1 = "Customer"
sum.code1 = 0
sum.field2 = "Customer"
sum.code2 = 2
sum.field3 = "Truck_Cost"
sum.code3 = 1
sum.field4 = "SELL_PRICE"
sum.code4 = 1
sum.field5 = "MARGIN"
sum.code5 = 1
sum.field6 = "MARGIN"
sum.code6 = 5
sum.field7 = "TOTAL_PCS"
sum.code7 = 1
sum.field8 = "TOTAL_WEIGHT"
sum.code8 = 1
tbl.summarize()
GOTO CONTINUE3011200714052484
ERROR3011200714052484:
ON ERROR GOTO 0
ui_msg_box("Error","Error running Summarize Operation"+crlf()+error_text_get())
END
CONTINUE3011200714052484:
tbl.close()
'Add the table just created by the Summarize operation to the Database..
file_add_to_db(summarize_db_name)
Comment