AnsweredAssumed Answered

FindField issues

Question asked by cdebruin on Nov 12, 2012
Latest reply on Nov 14, 2012 by cdebruin

I'm attempting to Load a combobox from a coded value domain and my function continues to fail at this line:

pFieldNum = inputTable.Fields.FindField(inputFieldName)

It complies nicely, so I'm not sure what the issue is. The error is just 'variable not set to an instance of an object.'
Doesn't tell me much.

Public Sub LoadCVDToCbx(inputTable As ITable, inputFieldName As String, cbxInput As ComboBox)
        'CJD 11/09/2012
        'Load values from a coded value domain into a specified combobox

        'clear combobox items

        Dim pDomain As IDomain
        Dim pCVD As ICodedValueDomain
        Dim pFieldNum As Long
        Dim pField As IField
        Dim i As Integer

        'get index of inputFieldName
        pFieldNum = inputTable.Fields.FindField(inputFieldName)
        If pFieldNum = -1 Then
            MsgBox("Specifield field not found in the table." & vbCrLf & _
               "Failed to load selection for combo box " & cbxInput.Name & ".", vbExclamation, "GDSE Error")
            Exit Sub
        End If

        'find field from index number
        pField = inputTable.Fields.Field(pFieldNum)
        'assign domain from the selected field
        pDomain = pField.Domain
        If TypeOf pDomain Is ICodedValueDomain Then
            pCVD = pDomain
            For i = 0 To pCVD.CodeCount - 1
                cbxInput.Items.Add(CStr(pCVD.Value(i)) & " " & CStr(pCVD.Name(i)))
            Next i
        End If

        Exit Sub

    End Sub