水晶报表在连接mdb文件时能否有选择条件?例如:只连接t1.code=’1’的内容.
水晶报表.datasour=rs
rs 是一個有有條件的SQL語句
如
AdoRs.Open SqlStr, Cn1, adOpenKeyset, adLockReadOnly , adLockBatchOptimistic
Dim m_Report As CrysRNewJob
Set m_Report = New CrysRNewJob
Me.MousePointer = vbHourglass
m_Report.Database.SetDataSource AdoRs
m_Report.Database.Verify
CRViewer1.ReportSource = m_Report
CRViewer1.ViewReport
你可以这样做:
m_Report.RecordSelectionFormula = "{t1.code} = 1"
CRViewer1.Refresh
当不需要时改为:
m_Report.RecordSelectionFormula = ""