水晶報表的數據源問題?
Private Sub Command1_Click()
Set Conn = New ADODB.Connection
If Conn.State = adStateOpen Then Conn.Close
With Conn
.ConnectionString = "Provider=SQLOLEDB.1;Password=12345;Persist Security Info=True;User ID=develop;Initial Catalog=huang;Data Source=sdb_server"
.CommandTimeout = 0
.Open
End With
Set Rs = New ADODB.Recordset
Dim Strsql As String
Strsql = "select top 10 person_no,card_no,person_name from person " '--->就是這個數據源
Rs.Open Strsql, Conn, adOpenKeyset, adLockReadOnly
If Rs.EOF Then Exit Sub
Form2.Show 1
End Sub
Form2的代碼如下:
Private Sub Form_Load()
Dim oApp As New CRAXDRT.Application
Dim oRpt As CRAXDRT.Report
Dim ReportName As String
ReportName = "\Rep_ks.rpt"
Screen.MousePointer = 11
Set oRpt = oApp.OpenReport(App.Path & ReportName)
oRpt.Database.SetDataSource Rs '-->就是這個數據源
oRpt.Database.Verify
CRViewer91.ReportSource = oRpt
CRViewer91.ViewReport
Screen.MousePointer = 0
End Sub
Private Sub Form_Resize()
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = ScaleHeight
CRViewer91.Width = ScaleWidth
End Sub
同樣的代碼,有一個可以改變水晶報表的數據源,另一個改變不了?也就是說用水晶報表的引導建立的數據源,在VB裡想用調用這個報表時,我要根據不同的條件顯示不同的數據。
如何做?請各位大俠指教!!!