pls use a view to find out all the tables then use this view to create a crystal template last call the .rpt file in vb program
:这是Crystal Report 9数据库各表打印的基本语句. 请结合你具体再改改即可.应该说,不太难;略费点劲.Option Explicit ------- 'dim Report as New Cystal1 '上面一行取消 Private Sub Form_Load() Dim oApp As New CRAXDRT.Application Dim oRpt As CRAXDRT.Report Dim reportName As String '上面三行是新增加的 Screen.MousePointer = vbHourglass reportName = "\rpt\Pr1.rpt" '定义要引用的rpt文件 Set oRpt = oApp.OpenReport(App.Path & reportName, 1) oRpt.Database.SetDataSource rs '连接水晶报表和数据源 oRpt.ReadRecords CRViewer91.ReportSource = oRpt '启用水晶报表的预览功能
CRViewer91.ViewReport Screen.MousePointer = vbDefault End Sub Private Sub Form_Resize() CRViewer91.Top = 0 CRViewer91.Left = 0 CRViewer91.Height = ScaleHeight CRViewer91.Width = ScaleWidth End Sub Private Sub Form_Unload(Cancel As Integer) 'Set Report = Nothing Set rs = Nothing Set conn = Nothing Unload Form2 End Sub
then use this view to create a crystal template
last call the .rpt file in vb program
请结合你具体再改改即可.应该说,不太难;略费点劲.Option Explicit
-------
'dim Report as New Cystal1
'上面一行取消
Private Sub Form_Load()
Dim oApp As New CRAXDRT.Application
Dim oRpt As CRAXDRT.Report
Dim reportName As String
'上面三行是新增加的
Screen.MousePointer = vbHourglass
reportName = "\rpt\Pr1.rpt" '定义要引用的rpt文件
Set oRpt = oApp.OpenReport(App.Path & reportName, 1)
oRpt.Database.SetDataSource rs '连接水晶报表和数据源
oRpt.ReadRecords
CRViewer91.ReportSource = oRpt '启用水晶报表的预览功能
CRViewer91.ViewReport
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize()
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = ScaleHeight
CRViewer91.Width = ScaleWidth
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Set Report = Nothing
Set rs = Nothing
Set conn = Nothing
Unload Form2
End Sub