水晶报表在连接mdb(表为:T1)文件时能否有选择条件?例如:只连接t1.code=’1’的内容.

解决方案 »

  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
      

  2.   

    你可以这样做:
            m_Report.RecordSelectionFormula = "{t1.code} = '1'"
            CRViewer1.Refresh
            当不需要时改为:
            m_Report.RecordSelectionFormula = ""