用关联表,这里有例子:
http://www.foxtable.com/help/topics/2479.htm
不过帮助的代码不是最好的,更好的方法有两个:
方法一
用SQLGroupTableBuilder,在窗口或者菜单新建一个按钮,将其代码设置为:
Dim gb As new SQLGroupTableBuilder("统计表","零件用量")
gb.AddTable("零件用量","产品","生产计划","产品")
gb.Groups.AddDef("零件")
gb.Totals.AddExp("需求数量","[生产数量] * [用量]")
gb.Build()
MainTable = Tables("统计表")
方法二
用SQLJoinTableBuilder,在窗口或者菜单新建一个按钮,将其代码设置为:
Dim jb As new SQLJoinTableBuilder("统计表","零件用量")
jb.AddTable("零件用量","产品","生产计划","产品")
jb.AddCols("零件",True)
jb.AddExp("需求数量","sum([生产数量] * [用量])")
jb.Build()
MainTable = Tables("统计表")