用vb带的DataReport做报表
我用的数据库是变化的
我用dim rs as new adodb.recordset 
我想在预览时怎么让rs中的记录显示出来。
DataReport中的rpttextbox控件怎么用

解决方案 »

  1.   

    Dim objcon As New ADODB.Connection
    Dim objrs As New ADODB.Recordset
    objcon.Open "provider=sqloledb.1;user id=sa;password=111;datasource=;initial catalog=111"
    objrs.Open "select * from table", 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 = "字段1"
    .Sections(3).Controls("Text2").DataField = "字段2"
    .Sections(3).Controls("Text3").DataField = "字段3"
    End With
    DataReport1.Show
      

  2.   

    设置报表的DataSource为查询后的记录集就可以了