循环遍历报表中的控件m_CRReport.FormulaFields.Item(0) 为什么不能从0开始

解决方案 »

  1.   

    给你参考下
        dim ctl as object
        For Each ctl In Me.Sections.Item("Section1").Controls
            If TypeName(ctl) = "RptTextBox" Then
                Select Case ctl.Name
                Case "Text1"
                    '……
                Case "Text2"
                    ctl.DataField = rs(0).Name'rs是你的记录集.
                Case "Text3"
                    ctl.DataField = rs(1).Name
                Case "Text4"
                    ctl.DataField = rs(2).Name
                End Select
            End If
        Next
      

  2.   

    先谢谢这位le
      我的意思是这个for循环从零开始时 m_CRReport.FormulaFields.Item(0). 就报错
    Dim aCnt As Integer
        For aCnt = 1 To m_CRReport.FormulaFields.Count    
           MsgBox ("This is a Contorl" & Space(2) & m_CRReport.FormulaFields.Item(aCnt).Name)
                    
           m_CRReport.FormulaFields.Item(aCnt).Text = "'" & "ATestNumber" & "'"
          'MsgBox ("the control text is " & Space(2) & m_CRReport.FormulaFields.GetItemByName(aCnt).Text)
        Next
    End Sub
     请各位帮忙想想