Adding Data from Form into Table

chris.blinn799

New member
Local time
Yesterday, 18:54
Joined
Oct 28, 2009
Messages
4
I'm trying to create a new feature in a feature class, then load it's field data from a form I created. The created feature is a land parcel. Not sure how to fix my "Object Required" error.



Code:
Public Sub UserForm_Initialize()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    
    Dim pParcelMaps As IMaps
    Set pParcelMaps = pMxDoc.Maps
    
    Dim pParcelMap As IMap
    Set pParcelMap = pParcelMaps.Item(0)

    Dim pSurveyedAreaFLayerDef As IFeatureLayerDefinition
    Set pSurveyedAreaFLayerDef = pParcelMap.Layer(1)
    
    Dim pToDoAreaFLayerDef As IFeatureLayerDefinition
    Set pToDoAreaFLayerDef = pParcelMap.Layer(2)
    
    Dim pSurveyedAreaFLayer As IFeatureLayer
    Set pSurveyedAreaFLayer = pSurveyedAreaFLayerDef
    
    Dim pToDoAreaFLayer As IFeatureLayer
    Set pToDoAreaFLayer = pToDoAreaFLayerDef
    
    Dim pSurveyedAreaFClass As IFeatureClass
    Set pSurveyedAreaFClass = pSurveyedAreaFLayer.FeatureClass
    
    Dim pToDoAreaFClass As IFeatureClass
    Set pToDoAreaFClass = pToDoAreaFLayer.FeatureClass
        
    
        
End Sub

Private Sub cmdCancel_Click()
    frmSurvey.Hide
End Sub

Private Sub Add(ByVal pFeature As IFeature)
    Dim pFeature As IFeature
    Set pFeature = New feature
    
    pFeature.FeatureType = esriGeometryPolygon
    
    Dim pClassName As IClassName
    Set pClassName = pFeature.Class
    
    pFeature.Class = pSurveyedAreaFClass
    
End Sub

Private Sub cmdSave_Click()
    
    Dim pFCursor As IFeatureCursor
    Set pFCursor = pSurveyedAreaFClass.Search(pFeature, True) '424 Run Time Error ???????????????
    Set pFeature = pFCursor.NextFeature
    
    pFeature.Value(1) = pPolygon
    pFeature.Value(2) = txtMAPPLAT.Value
    pFeature.Value(3) = txtREALMAPCOD.Value
    pFeature.Value(4) = txtREALSTNO.Value
    pFeature.Value(5) = txtREALSTNAME.Value
    pFeature.Value(6) = txtREALAPTNO.Value
    pFeature.Value(7) = txtSUBNAME.Value
    pFeature.Value(8) = txtNAMNAME.Value
    pFeature.Value(9) = txtNAMADDR.Value
    pFeature.Value(10) = txtNAMCITY.Value
    pFeature.Value(11) = txtNAMST.Value
    pFeature.Value(12) = txtNAMZIP.Value
    pFeature.Value(13) = txtNAMZIPEXT.Value
    
    
    
    pFeature.Value(17) = txtSDDISTRICT.Value
    
    pFeature.Value(19) = txtSURVEY_NUM.Value
    pFeature.Value(20) = txtGROUP_NUM.Value
    pFeature.Value(21) = txtHIST_NAME.Value
    pFeature.Value(22) = txtOTHER_NAME.Value
    pFeature.Value(23) = txtSTREET_NUM.Value
    pFeature.Value(24) = txtSTREET.Value
    pFeature.Value(25) = txtOLD_ADDRES.Value
    pFeature.Value(26) = txtCITY_COMM.Value
    pFeature.Value(27) = txtNR_DESIG.Value
    pFeature.Value(28) = txtLOCAL_DESI.Value
    pFeature.Value(29) = txtUSGS_MAPNU.Value
    pFeature.Value(30) = txtPVA_MAPNUM.Value
    pFeature.Value(31) = txtORIG_USE.Value
    pFeature.Value(32) = txtCUR_USE.Value
    pFeature.Value(33) = txtDOC.Value
    pFeature.Value(34) = txtSTYLE.Value
    pFeature.Value(35) = txtDEMOED.Value
    pFeature.Value(36) = txtNOTES.Value
            
    
            
    pFCursor.UpdateFeature pFeature
            Set pFeature = pFCursor.NextFeature
End Sub
Please Help

And thank you to those who helped me with formatting!
 
Last edited:
hi Chris. Just wanted to point something out that may help later on. Your post is a bit lengthy, which might sit for awhile before someone comes along who has time to read and analyze it. Just pointing that out. If you can say something in a short paragraph, that is always better...

btw, the code tags are wrapped with [] :)
 
btw, the code tags are wrapped with [] :)

The easiest way to wrap someting in code or quote tags is in the Advanced View. The # button (second from thre right) is for code.

The close tags include a forward slash (like html).
 
It is a bit difficult to determine from your description but it sounds to me like the two tables hold the same kind of data and their separation is arbitrary. You may be better to put them in the same table and include a field to indicate the "feature class".

If you have all the same fields in both tables then this is definitely the case.
 
Unfortunately, the two feature classes do not have the same fields. The only similarities between the feature classes are their Geometry types.
 
To better clarify my goal, I am looking at land parcels that need to be surveyed. I also have a feature class of land parcels that already have been surveyed. The form I created allows the user to fill in the surveyed information. I want the user to click on the to-be surveyed land parcels (using the select features tool), fill in the form, hit save, and have that land parcel added to the surveyed land parcels feature class. Once the new feature is added, I want the land parcel from the to-be surveyed feature class to be deleted. That part of my code is not listed however.

I hope this clears up any confusion.
 

Users who are viewing this thread

Back
Top Bottom