在修改上个世纪末开发的一个系统时,首次使用了水晶报表,加上是英文版,遇到了不少对于我来说的新鲜问题:
1.如何实现报表与VB程序之间的参数传递--使用formulas:
示例:Crp2.ReportFileName = App.Path + "\test.rpt"
Crp2.Formulas(0) = "name=" & "{mhpinyin.name}" ‘为第一个变量formulas赋值,name是formulas的ID
Crp2.Action = 1
2.如何有选择地打印相关数据:
示例:Crp2.ReportFileName = App.Path + "\test.rpt"
Crp2.SelectionFormula = "{mhpinyin.xh}>3 " ’只将序号xh大于3的记录打印
Crp2.Formulas(0) = "name=" & "{mhpinyin.name}"
Crp2.Action = 1
3.如何对所选域的值进行重新定义:
Crp2.ReportFileName = App.Path + "\test.rpt"
Crp2.SelectionFormula = "{mhpinyin.xh}>3 "
Crp2.Formulas(0) = "name=" & "{mhpinyin.name}"
Crp2.Formulas(1) = "xh=" & "If{mhpinyin.xh}=4 Then '定义1' Else '定义2'" '当序号xh等于4时,将‘定义1’赋予xh,若不等于4,则赋值‘定义2’
Crp2.Action = 1 另外,在同一窗体最好不要使用两个水晶控件,否则当分别调用打印后,当关闭当前窗体时,VB平台将报异常,并强行退出。如果需要调用两个报表模板时,可根据相关条件分别对Crp的ReportFileName的值进行分别赋值,然后调用。希望此帖能对同志们有所帮助!待续....
1.如何实现报表与VB程序之间的参数传递--使用formulas:
示例:Crp2.ReportFileName = App.Path + "\test.rpt"
Crp2.Formulas(0) = "name=" & "{mhpinyin.name}" ‘为第一个变量formulas赋值,name是formulas的ID
Crp2.Action = 1
2.如何有选择地打印相关数据:
示例:Crp2.ReportFileName = App.Path + "\test.rpt"
Crp2.SelectionFormula = "{mhpinyin.xh}>3 " ’只将序号xh大于3的记录打印
Crp2.Formulas(0) = "name=" & "{mhpinyin.name}"
Crp2.Action = 1
3.如何对所选域的值进行重新定义:
Crp2.ReportFileName = App.Path + "\test.rpt"
Crp2.SelectionFormula = "{mhpinyin.xh}>3 "
Crp2.Formulas(0) = "name=" & "{mhpinyin.name}"
Crp2.Formulas(1) = "xh=" & "If{mhpinyin.xh}=4 Then '定义1' Else '定义2'" '当序号xh等于4时,将‘定义1’赋予xh,若不等于4,则赋值‘定义2’
Crp2.Action = 1 另外,在同一窗体最好不要使用两个水晶控件,否则当分别调用打印后,当关闭当前窗体时,VB平台将报异常,并强行退出。如果需要调用两个报表模板时,可根据相关条件分别对Crp的ReportFileName的值进行分别赋值,然后调用。希望此帖能对同志们有所帮助!待续....
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货