水晶报表不刷新?

yangjh5632 2009-11-14 08:48:54
我用查询把内容输出到text1.xls文件中,在用水晶报表把内容一项一项打出来。但是水晶报表的内容还是第一次查询的没有随着查询的变化而变化。为什么?这样刷新呢?
请求高手相助!
不胜感激!
我用的是 VB6.0,execl2003,和9.0的水晶报表
...全文
236 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackterq 2009-12-11
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 neder2 的回复:]
只要在水晶报表编辑器,将[数据和报表一起保存]的“勾”去掉,存盘即可。再显示的数据与数据源保持同步。快动手吧!祝成功!
[/Quote]

果然是高手...解決了我多日來一直苦惱的問題...非常感謝neder2前輩
yangjh5632 2009-11-19
  • 打赏
  • 举报
回复
感谢各位,尤其是nerder2,
yangjh5632 2009-11-17
  • 打赏
  • 举报
回复
转贴参考):特别是标红字的地方,一定要清空历史数据
Dim rst As New ADODB.Recordset

Dim props As CRAXDRT.ConnectionProperties '报表数据源参数集
Dim prop As CRAXDRT.ConnectionProperty '报表数据源参数

'--------------------------------------------------
'构建与定义的记录集对应的数据集结构来模拟一次数据库操作
'以下的操作可以替换成任意的过程,最终目的就是处理成一个记录集
'作为报表的数据来源
'--------------------------------------------------
Set rst = New ADODB.Recordset

rst.Open "pjrpt", db, adOpenKeyset, adLockOptimistic
'能不能换成EXECL格式

'创建报表
'--------------------------------------------------
'加载报表模板
Set objCRReport = objCRApp.OpenReport(App.Path & "\PjRpt.rpt", 1)

'加载报表字段定义文件
Set props = objCRReport.Database.Tables(1).ConnectionProperties
For Each prop In props
If InStr(prop.Name, "Field Definition File") > 0 Then
prop.Value = App.Path & "\PjRpt.ttx" '字段定义文件-PjRpt.ttx PjRpt.ttx
Exit For
End If
Next
Set props = Nothing

'清除报表中保持的数据
objCRReport.DiscardSavedData
objCRReport.EnableParameterPrompting = False '不进行报表参数提示


'赋给报表数据
objCRReport.Database.SetDataSource rst
'--------------------------------------------------



'进行报表显示外观设置
'--------------------------------------------------

objCRReport.LeftMargin = 260 '左边距
objCRReport.RightMargin = 10 '右边距



CRViewer91.EnableExportButton = True '导出按钮
' CRViewer91.EnableSelectExpertButton = True
' CRViewer91.DisplayGroupTree = False '不显示组树
' CRViewer91.EnableAnimationCtrl = False
' CRViewer91.EnableCloseButton = False
' CRViewer91.EnableGroupTree = False
' CRViewer91.EnableHelpButton = False
' CRViewer91.EnableRefreshButton = False
CRViewer91.EnableNavigationControls = True '显示总页数和下一页
' CRViewer91.EnablePopupMenu = False
' CRViewer91.EnableSearchControl = False
' CRViewer91.EnableSearchExpertButton = False '查找
' CRViewer91.EnableSelectExpertButton = False
' CRViewer91.DisplayTabs = False

CRViewer91.DisplayBackgroundEdge = False
CRViewer91.EnableAnimationCtrl = False
CRViewer91.EnableCloseButton = False
CRViewer91.EnableGroupTree = False
CRViewer91.EnableHelpButton = False
CRViewer91.EnableRefreshButton = False
CRViewer91.EnableSearchExpertButton = False
CRViewer91.EnableSelectExpertButton = False

'指定报表来源
CRViewer91.ReportSource = objCRReport
'显示报表
CRViewer91.ViewReport

Set rst = Nothing
小雨点 2009-11-17
  • 打赏
  • 举报
回复
只要在水晶报表编辑器,将[数据和报表一起保存]的“勾”去掉,存盘即可。再显示的数据与数据源保持同步。快动手吧!祝成功!
jieweibin 2009-11-17
  • 打赏
  • 举报
回复
rst.Open "pjrpt", db, adOpenKeyset, adLockOptimistic
'能不能换成EXECL格式
把记录源换成excel文件形式不就行了?网上很多吧,你自己搜了改一下,我没用过excel的
jieweibin 2009-11-16
  • 打赏
  • 举报
回复
(转贴参考):特别是标红字的地方,一定要清空历史数据
Dim rst As New ADODB.Recordset

Dim props As CRAXDRT.ConnectionProperties '报表数据源参数集
Dim prop As CRAXDRT.ConnectionProperty '报表数据源参数

'--------------------------------------------------
'构建与定义的记录集对应的数据集结构来模拟一次数据库操作
'以下的操作可以替换成任意的过程,最终目的就是处理成一个记录集
'作为报表的数据来源
'--------------------------------------------------
Set rst = New ADODB.Recordset

rst.Open "pjrpt", db, adOpenKeyset, adLockOptimistic


'创建报表
'--------------------------------------------------
'加载报表模板
Set objCRReport = objCRApp.OpenReport(App.Path & "\PjRpt.rpt", 1)

'加载报表字段定义文件
Set props = objCRReport.Database.Tables(1).ConnectionProperties
For Each prop In props
If InStr(prop.Name, "Field Definition File") > 0 Then
prop.Value = App.Path & "\PjRpt.ttx" '字段定义文件-PjRpt.ttx PjRpt.ttx
Exit For
End If
Next
Set props = Nothing

'清除报表中保持的数据
objCRReport.DiscardSavedData

objCRReport.EnableParameterPrompting = False '不进行报表参数提示


'赋给报表数据
objCRReport.Database.SetDataSource rst
'--------------------------------------------------



'进行报表显示外观设置
'--------------------------------------------------

objCRReport.LeftMargin = 260 '左边距
objCRReport.RightMargin = 10 '右边距



CRViewer91.EnableExportButton = True '导出按钮
' CRViewer91.EnableSelectExpertButton = True
' CRViewer91.DisplayGroupTree = False '不显示组树
' CRViewer91.EnableAnimationCtrl = False
' CRViewer91.EnableCloseButton = False
' CRViewer91.EnableGroupTree = False
' CRViewer91.EnableHelpButton = False
' CRViewer91.EnableRefreshButton = False
CRViewer91.EnableNavigationControls = True '显示总页数和下一页
' CRViewer91.EnablePopupMenu = False
' CRViewer91.EnableSearchControl = False
' CRViewer91.EnableSearchExpertButton = False '查找
' CRViewer91.EnableSelectExpertButton = False
' CRViewer91.DisplayTabs = False

CRViewer91.DisplayBackgroundEdge = False
CRViewer91.EnableAnimationCtrl = False
CRViewer91.EnableCloseButton = False
CRViewer91.EnableGroupTree = False
CRViewer91.EnableHelpButton = False
CRViewer91.EnableRefreshButton = False
CRViewer91.EnableSearchExpertButton = False
CRViewer91.EnableSelectExpertButton = False

'指定报表来源
CRViewer91.ReportSource = objCRReport
'显示报表
CRViewer91.ViewReport

Set rst = Nothing
Flyingdragon168 2009-11-16
  • 打赏
  • 举报
回复
1、如果你水晶報表是直接放在工程中的,那你在每次調用報表後,要及時把水晶報表關閉,否則只要你程式未關閉,再次打開時,總是你第一次打開的內容。
2、如果你的報表文件不放在工程中,而是通過臨時表加載數據,則你要檢查一下你的臨時表中,數據有沒有問題,另外,再在你把數據加到臨時表中,增加一下延時,因為有時電腦速度太快,水晶報表不能及時顯示正確數據。
yangjh5632 2009-11-16
  • 打赏
  • 举报
回复
我把查询结果用ADO把数据导出到EXECL中,在想把每一条记录通过水晶报表(已做好模版,且数据一一对应),为什么数据还是显示对应的第一次数据。
  • 打赏
  • 举报
回复
问题叙述的不详细
贝隆 2009-11-14
  • 打赏
  • 举报
回复
代码呢?最好把代码贴出来

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧