Create new layer from joined feature class

Discussion created by USForestServiceAdmin on Mar 22, 2011
Hello all,

I have joined a standalone table called Less250_temp_Frequency to a shapefile layer using Visual Studio 2008 Visual Basic.  I am now wanting to create a new layer using a field called ACRES_CL from the joined table.  The code below references pFc, which is the feature class of the joined layer, but its only getting the feature class of the layer, not the joined part of the layer.  How do I get pfc to reference the joined layer so I have access to all the fields in the join?

            pQF.WhereClause = "Less250_temp_Frequency.ACRES_CL < 250"
            WSF = New ShapefileWorkspaceFactory
            WS = Nothing
            FWS = Nothing

            pFc = pFLayer.FeatureClass

            'Get the Featureclassname from the Clip featureclass
            pDataset = pFc
            pInFeatureClassName = pDataset.FullName
            pInDsName = pInFeatureClassName

            'Define the output featureclass
            'give it the name thats on the form
            pFeatureClassName = New FeatureClassName
            pOutDatasetName = pFeatureClassName
            pOutDatasetName.Name = Me.txtName.Text
            pWorkspaceName = New WorkspaceName
            pWorkspaceName.PathName = Me.txtPath.Text
            pWorkspaceName.WorkspaceFactoryProgID = "esriCore.shapefileworkspacefactory.1"
            pOutDatasetName.WorkspaceName = pWorkspaceName

            'Give the output shapefile the same props as the input dataset
            pFeatureClassName.FeatureType = pFc.FeatureType
            pFeatureClassName.ShapeType = pFc.ShapeType
            pFeatureClassName.ShapeFieldName = pFc.ShapeFieldName

            'Export selected features
            pExportOp = New ExportOperation
            pExportOp.ExportFeatureClass(pInDsName, pQF, Nothing, Nothing, pOutDatasetName, 0)

                pFc = FWS.OpenFeatureClass(Me.txtName.Text)
                pFLess250Layer = New FeatureLayer
                pFLess250Layer.FeatureClass = pFc
                pFLess250Layer.Name = Me.txtName.Text