This is a migrated thread and some comments may be shown as answers.

Index was outside the bounds of the array

1 Answer 242 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chuck Harrington
Top achievements
Rank 1
Chuck Harrington asked on 24 Sep 2010, 11:24 PM
Dim section As Processing.DetailSection = DirectCast(sender, Processing.DetailSection)
        Dim dobj As Processing.IDataObject = DirectCast(section.DataObject, Processing.IDataObject)
        Dim txtbxComment = DirectCast(section.ChildElements.Find("txtComment", True)(0), Processing.TextBox)
        Dim txtbxOTRelief = DirectCast(section.ChildElements.Find("txtOTRelief", True)(0), Processing.TextBox)
        Dim txtbxOTTrain = DirectCast(section.ChildElements.Find("txtOTTrain", True)(0), Processing.TextBox)
        Dim txtbxOTSched = DirectCast(section.ChildElements.Find("txtOTSched", True)(0), Processing.TextBox)
        Dim txtbxOTOther = DirectCast(section.ChildElements.Find("txtOTOther", True)(0), Processing.TextBox)
        Dim txtbxVacAvail = DirectCast(section.ChildElements.Find("txtVacAvail", True)(0), Processing.TextBox)
        Dim txtbxVacUsed = DirectCast(section.ChildElements.Find("txtVacUsed", True)(0), Processing.TextBox)
        Dim txtbxVacRemain = DirectCast(section.ChildElements.Find("txtVacRemain", True)(0), Processing.TextBox)
        Dim txtbxPCHAvail = DirectCast(section.ChildElements.Find("txtPCHAvail", True)(0), Processing.TextBox)
        Dim txtbxPCHUsed = DirectCast(section.ChildElements.Find("txtPCHUsed", True)(0), Processing.TextBox)
        Dim txtbxPCHRemain = DirectCast(section.ChildElements.Find("txtPCHRemain", True)(0), Processing.TextBox)
        Dim txtbxPPNbr = DirectCast(section.ChildElements.Find("txtPPNbr", True)(0), Processing.TextBox)
        Dim txtbxOT = DirectCast(section.ChildElements.Find("txtOT", True)(0), Processing.TextBox)
        Dim txtbxWorkDate = DirectCast(section.ChildElements.Find("txtWorkDate", True)(0), Processing.TextBox)
 
        txtbxPPNbr.Value = Get_PayPeriod(dobj("TTD_WORK_DATE"))
 
        If txtbxOT.Value > 0 Then
            If InStr(1, txtbxComment.Value, "Relief") > 0 Then
                txtbxOTRelief.Value = txtbxOT.Value
                sglOTRelief += txtbxOT.Value
            ElseIf InStr(1, txtbxComment.Value, "Train") > 0 Then
                txtbxOTTrain.Value = txtbxOT.Value
                sglOTTrain += txtbxOT.Value
            ElseIf InStr(1, txtbxComment.Value, "Sched") > 0 Then
                txtbxOTSched.Value = txtbxOT.Value
                sglOTSched += txtbxOT.Value
            Else
                txtOTOther.Value = txtbxOT.Value
                sglOTOther = txtbxOT.Value
            End If
        End If
 
Public Shared Function Get_PayPeriod(ByVal dtWorkDate As Date) As Integer
        Dim intX As Integer = 0
        Dim avarPayPeriods() As TCCPayPeriods = aPayPeriods
 
        For intX = 0 To UBound(avarPayPeriods)
            If dtWorkDate >= avarPayPeriods(intX).dtPayPeriod And intX = 23 Then
                Return avarPayPeriods(intX).bytPayPeriodNbr
                Exit For
            ElseIf dtWorkDate >= avarPayPeriods(intX).dtPayPeriod And dtWorkDate < avarPayPeriods(intX + 1).dtPayPeriod Then
                Return avarPayPeriods(intX).bytPayPeriodNbr
                Exit For
            End If
        Next intX
    End Function
Hello,
I received this error when trying to process a detail section of a report.  I am referencing the fields as follows:


Assume TCCPayPeriods structure defined correctly.  Any ideas what I am doing wrong.  Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Chuck Harrington
Top achievements
Rank 1
answered on 27 Sep 2010, 05:14 PM
I resolved my problem with this.  It was not due to the code but some missing textbox names which caused the error referred to in my original post.  Once I added the correct report definition textbox names, the report ran successfully.
Tags
General Discussions
Asked by
Chuck Harrington
Top achievements
Rank 1
Answers by
Chuck Harrington
Top achievements
Rank 1
Share this question
or