Hello all - I have a functon that was developed by another developer that I was asked to trouble shoot.
In the form, the user clicks a button to add an element to a row, wherever in the reow they choose.
but the script seems to fail if , and I get the subscript out of range error on the line:
NewField(j) = Field(k) 'transfer value from existing field to new field.
Function ExpandField(Field As Variant) As Variant
'********************************************************************************************************
'* Created: January 5, 1998
'* Author: Betsy Thiede (Richmond Information Group) with much help from Gary Shifflett
'* Purpose: Adds a new blank element to each field in the dynamic table in prepartion for the insertion of the new element
'* Parameters: None
'* Called by: GetCurrentFields subroutine
'********************************************************************************************************
Dim NewField() As String 'Array to temporarily store the new "expanded" field.
Dim J As Integer 'Index counter for new field
Dim K As Integer 'Index counter for existing field.
Redim NewField(Ubound(field)+1)
k = 0
For j=0 To Ubound(field) + 1
If J <> InsertionPoint Then
NewField(j) = Field(k) 'transfer value from existing field to new field.
k = k + 1
Else
Newfield(j) = "" 'setting the new field's element to blank(k not incremented. J & K are now out of sync by one)
End If
Next
Expandfield = newfield
End Function