数据报表里可增加一些新的计算和合计的字段
但我想实现,当程序运行时,报表能按照输入的一些查询条件来显示数据,例如设置一个TEXT控件,输入abc,此时报表中输出的数据是“select * from table where name=abc”
实际上我就是不知道如何把查询条件与输出的数据结合起来
就像我用DATAGRID控件绑定ADODC控件时,更改了ADODC的RECORDSOUCE,那么DATAGRID中的数据也就有了响应的变化望解答一下,谢谢

解决方案 »

  1.   

    Private Sub Command3_Click()
    Dim objcon As New ADODB.Connection
    Dim objrs As New ADODB.Recordset
    objcon.Open "provider=sqloledb.1;user id=sa;password=csm@csm;datasource=;initial catalog=xiazaijiluziliao"
    objrs.Open "select * from table where name='& text1.text & "'", objcon, 1, 3
    Set DataGrid1.DataSource = objrs.DataSource
    'Me.Caption = objrs.RecordCount
    Set DataReport1.DataSource = DataGrid1.DataSource
    'DataReport1.DataMember = DataGrid1.DataMember
    With DataReport1
    .Sections(4).Controls("Label2").Caption = "共%P页第%p页"
    .Sections(2).Controls("label3").Caption = "打印日期:%d %t"'.Sections(3).Controls("Text1").DataMember = objrs.DataMember
    .Sections(3).Controls("Text1").DataField = "ziduan1"
    .Sections(3).Controls("Text2").DataField = "ziduan2"
    .Sections(3).Controls("Text3").DataField = "ziduan3"
    End With
    DataReport1.ShowEnd Sub
      

  2.   

    data report 的dataMember是一个command对象
    程序中可以动态设置command对象的数据源属性