水晶报表问题?

truesmx 2006-03-01 12:34:50
水晶报表10.0
Dim Report As New CrystalReport1'
Public strSql As String'要打印的数据
Public strReportName As String'报表文件夹

Private Sub CRViewer1_CloseButtonClicked(UseDefault As Boolean)

End Sub

Private Sub Form_Load()

Dim rs As New ADODB.Recordset
Dim oApp As New CRAXDRT.Application
Dim oRpt As CRAXDRT.Report
Dim strTemp As String

Screen.MousePointer = vbHourglass

'查找报表文件
Select Case strReportName
Case "0"
strReportName = "rclist.rpt"'这些文件已用水晶报表10.0做好。
Case "1"
strReportName = "rslistjb.rpt"
End Select

strTemp = App.Path

If Right(App.Path, 1) <> "\" Then strTemp = strTemp & "\"

strReportName = strTemp & "crystal\" & strReportName

If Dir(strReportName) = "" Then
MsgBox "没有找到报表文件!预览失败!", vbInformation, "提示"
Exit Sub
End If

strSql = "select top 10 * from q_RcList Order by person_nation desc"
'每次这个地方传过来的sql不更新,还是设计时的数据,是怎么回事,请大家指教?谢谢!
Set rs = ExSQL(strSql)
Debug.Print rs.RecordCount

'strReportName = "\crystal\rclist.rpt" '定义要引用的rpt文件

Set oRpt = oApp.OpenReport(strReportName, 1)

oRpt.Database.SetDataSource rs '连接水晶报表和数据源
oRpt.ReadRecords

CRViewer1.Refresh
'CRViewer1.PrintReport
CRViewer1.ReportSource = oRpt '启用水晶报表的预览功能

CRViewer1.ViewReport

Screen.MousePointer = vbDefault
End Sub
...全文
55 2 点赞 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
daisy8675 2006-03-02
strSql = "select top 10 * from q_RcList Order by person_nation desc"
'每次这个地方传过来的sql不更新,还是设计时的数据,是怎么回事,请大家指教?谢谢!
//是你的recordset不更新还是水晶报表???

水晶报表文件下有个菜单是保持以前的记录,默认是选种,你要把哪个勾去掉才行啊
  • 打赏
  • 举报
回复
zhanghanqin 2006-03-02
oRpt.DiscardSavedData '清空原有数据
  • 打赏
  • 举报
回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2006-03-01 12:34
社区公告
暂无公告