我现在要用水晶报表9.0实现这样一个功能,动态设置报表的数据源,动态添加控件(text,box,line)到报表,并且还要动态设置每个box与表中字段的连接!哪位高手能提供源码或相关书籍,资料等,小弟愿高分相送。

解决方案 »

  1.   

    Set m_Report = Nothing
        Set m_Report = m_Application.NewReport
        With m_Report.Database
            ' Add a datasource to the report.  The wizard will include any data
            ' source that has been added to the report
            
            Set Connection = New Connection
            Set m_Table = Nothing
            Set m_Table = CreateObject("adodb.recordset")
            Connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= " & App.Path & "\insight.mdb;Mode=Read"
            Connection.Open
            m_Table.Open "select * from tableset", Connection, adOpenDynamic, adLockPessimistic, adCmdText        While Not m_Table.EOF
                .AddOLEDBSource Connection, m_Table.Fields(1).Value
                m_Table.MoveNext
            Wend
        End With
        Set m_Wizard = New CRStandardWizard
        Set m_Wizard.CrystalReport = m_Report
        m_Wizard.DisplayReportWizard
        CRDesigner.ReportObject = m_Report
        Connection.Close
      

  2.   

    Dim m_Application as CRADDXT.Application
    Dim m_Report as CRADDXT.Report