Need Help in VBA code to access values of cell from joined DATABASE

Discussion created by abhishek_kumar on Jan 28, 2011

I am trying to access values from the cell that is in Database which is already joined by using arc join.

Private Sub UserForm_Initialize()
End Sub

Private Sub Populate_Transformer()
Dim pMxDoc As IMxDocument, pMap As IMap
Dim pFlayer As IFeatureLayer, pFClass As IFeatureClass
Dim pFields As IFields, pFilter As IQueryFilter
Dim pFCursor As IFeatureCursor, pFeature As IFeature
Dim i As Integer, j As Integer, iPosTransformerName As Integer, iPosTransformerNumber As Integer
Dim varArray() As Variant
  Set pMxDoc = ThisDocument
  Set pMap = pMxDoc.FocusMap
  For i = 0 To pMap.LayerCount - 1
    If pMap.Layer(i).Name = "TLM" Then
      Set pFlayer = pMap.Layer(i)
      Set pFClass = pFlayer.FeatureClass
Dim pTable As ITable
Dim pDisplayTable As IDisplayTable
    Set pDisplayTable = pFlayer
    Set pTable = pDisplayTable.DisplayTable
    If pTable Is Nothing Then
        MsgBox "The Layer is not Joined"
    End If
Dim pRelQueryTable As IRelQueryTable
Dim pDestTable As ITable
Dim pDataSet As IDataset
Dim strOut As String

    Do While TypeOf pTable Is IRelQueryTable
        Set pRelQueryTable = pTable
        Set pDestTable = pRelQueryTable.DestinationTable
        Set pDataSet = pDestTable
        strOut = strOut & pDataSet.Name & vbNewLine
        Set pTable = pRelQueryTable.SourceTable
    MsgBox "The Joined tables include: " & vbNewLine & strOut

<<<<< I need help here... i can see that my layers are joined together but i can't get to the feild name and also can't get the values from that feild.... feild name is OBJECTID and the table is tTLM in a database somewhere on shared drivve. Also if i can find the feild name tobe true i can't get to the value of its cell and query the whole calue there are around 1000 of them and put it in my form 
      Set pFields = pFClass.Fields
      iPosTransformerNumber = pFields.FindField("Grid Number")
      iPosTransformerName = pFields.FindField("OBJECTID")
      Set pFilter = New QueryFilter
      Set pFCursor = pFClass.Search(pFilter, True)
      Set pFeature = pFCursor.NextFeature
      ReDim varArray(0) 'initialize array
      Do Until pFeature Is Nothing
        ReDim Preserve varArray(UBound(varArray) + 1) 'increment array
         varArray(UBound(varArray)) = (pFeature.Value(iPosTransformerNumber)) _
         & pFeature.Value(iPosTransformerName)
         Set pFeature = pFCursor.NextFeature
      'Sort Array
      varArray = BubbleSortArray(varArray)
    ' populate cboTransformer rows with TransformerNumber and TransformerName
      For j = 1 To UBound(varArray)
        With Me.cboTransformer
          .AddItem (varArray(j) - 1)
          .Column(1, .ListCount - 1) = (varArray(j))
        End With 'Me.cboTransformer
      Next j
    End If
  Next i
End Sub