使用Formulas ,在你希望的地方放上Formulas ,方法是选择插入菜单下的Formulas选项,插入一个个的Formulas,就像grid的一个个cell
vb代码向fomula传递参数:
.ReportFileName = gsReportPath + "xsd.rpt" .Formulas(0) = "customer='" & Trim(ofrm.txt(1)) & "(" & Trim(ofrm.txt(0)) & ")'" '客户名称和编码
.Formulas(1) = "datetime='" & ofrm.msDatetime & "'" '审核日期时间
.Formulas(2) = "wrsname1='" & Trim(oFlg.TextMatrix(1, 0)) & "'" '发票第一行的物资名称
.Formulas(3) = "wrsname2='" & Trim(oFlg.TextMatrix(2, 0)) & "'" '发票第二行的物资名称
.Formulas(4) = "wrsname3='" & Trim(oFlg.TextMatrix(3, 0)) & "'" '发票第三行的物资名称
.Formulas(5) = "wrsname4='" & Trim(oFlg.TextMatrix(4, 0)) & "'" '发票第四行的物资名称
.Formulas(6) = "wrsname5='" & Trim(oFlg.TextMatrix(5, 0)) & "'" '发票第五行的物资名称
customer,wrsname1,wrsname2等是formulas的名字。
vb代码向fomula传递参数:
.ReportFileName = gsReportPath + "xsd.rpt" .Formulas(0) = "customer='" & Trim(ofrm.txt(1)) & "(" & Trim(ofrm.txt(0)) & ")'" '客户名称和编码
.Formulas(1) = "datetime='" & ofrm.msDatetime & "'" '审核日期时间
.Formulas(2) = "wrsname1='" & Trim(oFlg.TextMatrix(1, 0)) & "'" '发票第一行的物资名称
.Formulas(3) = "wrsname2='" & Trim(oFlg.TextMatrix(2, 0)) & "'" '发票第二行的物资名称
.Formulas(4) = "wrsname3='" & Trim(oFlg.TextMatrix(3, 0)) & "'" '发票第三行的物资名称
.Formulas(5) = "wrsname4='" & Trim(oFlg.TextMatrix(4, 0)) & "'" '发票第四行的物资名称
.Formulas(6) = "wrsname5='" & Trim(oFlg.TextMatrix(5, 0)) & "'" '发票第五行的物资名称
customer,wrsname1,wrsname2等是formulas的名字。
formulas是report的属性,上面的代码摘自我去年做的工程中,
应用程序至今在使用中,没问题的!!!!
调用时,依照上面的代码把值一个个传递过去。
注意不是.formulafields,
要不你把代码贴出来,我看看!!!
formulas是report的属性,上面的代码摘自我去年做的工程中,
应用程序至今在使用中,没问题的!!!!
调用时,依照上面的代码把值一个个传递过去。
注意不是.formulafields,
要不你把代码贴出来,我看看!!!
frmINCRPT.frm窗口的代碼如下﹕
Option Explicit
Dim Report As New crINC
Dim tmpSum As StringPrivate Sub Form_Load()
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefaultEnd Sub
crINC.dsr窗口的代碼如下﹕
Option ExplicitPrivate Sub Section4_Format(ByVal pFormattingInfo As Object)
crINC.FormulaFields.Item(1).Text = ChMoney(Val(Me.Field13.Value))
End Sub
請問我該把 ChMoney(Val(Me.Field13.Value))添加在哪個部份﹐怎么加﹖
如果你輔導我做出來后我給你再加40分﹐謝謝﹗
在上面添加一个叫aa的formula
然后在做新窗口,加一个报表控件(rpt),再加一个打印按钮,
按钮click事件写下如下代码:
dim sstr as string
sstr="test"
with me.rpt
.DataFiles(0) = "c:\temp.mdb" 'temp.mdb是必须的,里面一个表没有
表都没关系,必须有一个数据库,名字也可任意!!!
.ReportFileName = gsReportPath + "xsd.rpt"
.Formulas(0) = "aa='" & sstr & "'" 'sstr你谁遍赋值把
.Destination = crptToWindow '输出到屏幕
.printreport
with
执行窗口,点打印按钮看有什么结果!!!!
.ReportFileName = gsReportPath + "xsd.rpt"
应换成temp.rpt的路径
上去找一下
我寫了你給我代碼后﹐發現不能彈出預覽的窗口﹐看不了數據呀﹐我現在正等著米下鍋呀﹐可著急了呀
大致為,
Dim fld as String
Dim rptApp As CRAXDRT.Application '報表物件
Dim m_Rpt As CRAXDRT.Report '報表 rs.moveFirst
If rs.recordCout<10 then
For i=rs.recordcount to 10
rs.AddNew
for Each fld as rs.fields.name
rs.field.Item(fld).value=null
next Next
End if
'建立報表應用物件
Set rptApp = CreateObject("CrystalRuntime.Application")
'打開報表文件
Set m_Rpt = rptApp.OpenReport(strFileName)
m_Rpt.Database.SetDataSource rsRpt, 3, 1
m_Rpt.ReadRecords
me.CRViewer1.ReportSource = m_Rpt
me.CRViewer1.ViewReport
for Each fld as rs.fields.name-->For Each fld In rs.Fields.Count
當然這只是小于10筆記錄..
如果有多頁,只要先算到每頁有幾行..
再求余出來,也就一樣..
Dim rptApp As CRAXDRT.Application '報表物件
Dim m_Rpt As CRAXDRT.Report '報表 rs.moveFirst
If rs.recordCout<10 then
For i=rs.RecordCount to 10
rs.AddNew
For idx =0 to rs.fields.Count-1
rs.field(idx).value=null
next Next
End if
'建立報表應用物件
Set rptApp = CreateObject("CrystalRuntime.Application")
'打開報表文件
Set m_Rpt = rptApp.OpenReport(strFileName)
m_Rpt.Database.SetDataSource rsRpt, 3, 1
m_Rpt.ReadRecords
me.CRViewer1.ReportSource = m_Rpt
me.CRViewer1.ViewReport
Dim rptApp As CRAXDRT.Application '報表物件
這句話我就執行不下去了﹐我用的是crystal report 8.5的版本﹐vb6.0+pack5﹐不知道行不行呀
哪位有更好的方法
聽說可以在Crystal Report裡增加Formula實現控制Details記錄項的顯示
不知哪位大俠知道代碼?
關注中。。
在Details增加一個記數具(用來記靈Details的一字段顯示了多少個)
然後用一個判斷:如果是同一頁的,且記數具為11(想控制1頁10個記錄)
(上面的判斷我可以做到)
調到下一頁顯示(關健在這裡,如何調到下一頁)
連Formula都找不出來?
不會怕
直接按菜單下的Insert-->Field Object-->Formula Fields就可編Formula了
現在我已做到控制第一頁顯示固定的記錄,但要填上空行還要努力啊!
--------------------
|A B C |
|-------------------|
|1 2 3 |
|-------------------|
|-------------------|維啊!我再試試!