很多个不同的单位是说就像是不同的班级!不同班级的成绩混在一起,我该怎么控制呢?我用的是数据环境!
重复的数据怎么控制的??跪求!!还有就是怎么动态选不同班级的成绩?字段一样的!!
报表中的字段是 从不同的表中选出来的啊!

解决方案 »

  1.   

    Option ExplicitPrivate Sub DataReport_Initialize()        Dim cnn As New ADODB.Connection
            Dim rs As New ADODB.Recordset
            Dim str As String
            Dim strsql As String
            
            With cnn
                .Provider = "MSDataShape.1" '一定要加这句
                .Open "Provider=Microsoft.Jet.OLEDB.4.0; " _
                & "Data Source=" & App.Path & "\jysf.mdb;Persist " _
                & "Security Info=False;"
            End With        
            rs.CursorLocation = adUseClient
            
            strsql = "SELECT student.sclass, student.年, student.月, student.日, student.sname , student.sno, amounts.总额, amounts.学费, amounts.学杂费, amounts.住宿费, amounts.大写总额, amounts.学费代码, amounts.住宿费代码, amounts.收费单位代码, amounts.代管费, amounts.代管费总和, amounts.校服费, class.汉字班级 FROM amounts, student, class WHERE amounts.总额 =student.总额 AND student.sclass = class.sclass  "
                 '" & Chr(34) & Trim(form1.DataList1.Text) & Chr(34) & "order by  student.sclass "      'SQL语句可以用变量"
            rs.Open strsql, cnn, adOpenDynamic, adLockOptimistic
            
            Set DataReport1.DataSource = rs
            
            'Me.Sections.Item("Section1").Controls.Item("text1").DataField = rs.Fields(0).Value
             
            
            DataReport1.Sections(1).Controls("Text1").DataField = rs.Fields(0) & ""
            MsgBox DataReport1.Sections(1).Controls("Text1").DataField
            
            'DataReport1.Sections(1).Controls("Text2").DataField = rs.Fields(2) & ""
            'DataReport1.Sections(1).Controls("Text3").DataField = rs.Fields(3) & ""
            'DataReport1.Sections(1).Controls("Text4").DataField = rs.Fields(4) & ""
       
           'DataReport1.Sections("Section1").Controls("text1").DataField = rs.Fields(1)
           'DataReport1.Sections("Section1").Controls("text2").DataField = rs.Fields(2)
          ' DataReport1.Sections("Section1").Controls("text3").DataField = rs.Fields(3)
          ' DataReport1.Sections("Section1").Controls("text4").DataField = rs.Fields(4)
             
    End Sub
      ~~~~~~~~~~~~~
    为什么会越界的呢??