請問在水晶報表中怎樣可以讓重複的行只顯示一次,也就是怎樣才能加入distinct關鍵字,拜託,我真的找不到相關資料.
我想把
select field1,field2,..... from tab1,tab2,tab3 where condition
改為
select distinct filed1,filed2,..... from tab1,tab2,tab3 where condition
請問在那裡可以修改,怎麼改.
我想把
select field1,field2,..... from tab1,tab2,tab3 where condition
改為
select distinct filed1,filed2,..... from tab1,tab2,tab3 where condition
請問在那裡可以修改,怎麼改.
如下的代码是水晶报表生成的窗体的代码
记得引用ado啊
Dim rs As ADODB.Recordset
Dim Report As New CrystalReport1
Dim msgtext As String
Private Sub Form_Load()
Dim strsql As String
'这里你可以怎么做都可以,只要是sql语句就可以
strsql = "select * from dw_table where dw_bm='" & Form2.Text1.Text & "'"
Set rs = ExecuteSQL(strsql, msgtext)
Report.Database.SetDataSource rs
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End SubPrivate Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidthEnd SubPrivate Sub Form_Unload(Cancel As Integer)
Set Report = Nothing
End Sub下面的代码是函数ExecuteSQL
Dim msgtext As String
Dim mrc As ADODB.RecordsetPublic Function ExecuteSQL(ByVal sql As String, MsgString As String) As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim sTokens() As String
'Dim SQL As String
On Error GoTo ExecuteSQL_Error
sTokens = Split(sql)
Set cnn = New ADODB.Connection
cnn.Open ConnectString
If InStr("INSERT,DELETE,UPDATE", UCase$(sTokens(0))) Then
cnn.Execute sql
MsgString = sTokens(0) & "query successful"
Else
Set rst = New ADODB.Recordset
rst.Open Trim$(sql), cnn, adOpenKeyset, adLockOptimistic
Set ExecuteSQL = rst
MsgString = "查询到" & rst.RecordCount & "条纪录"
End If
ExecuteSQL_Exit:
Set rst = Nothing
Exit Function
Set cnn = Nothing
ExecuteSQL_Error:
MsgString = "查询错误:" & Err.Description
Resume ExecuteSQL_Exit
End FunctionPublic Function ConnectString() As String
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\计划管理系统.mdb;Persist Security Info=False"
End Function