Solved! Go to Solution.
Hey,
I'm making a model in Model Builder inside ArcGIS for Desktop 10 and running into the following problem:
I have a feature class that I want to select a portion of based on the entry in a specific field and then modify a different field in the same feature class for just the rows that were selected using Calculate Field. I've made a model that uses the "Select Layer By Attributes" to select the rows I wish to modify, and implemented the "Calculate Field" tool immediately after the "Select Layer By Attributes" tool to modify another field within the feature class.
My problem is the "Calculate Field" tool modifies every row in the attribute table for the feature class instead of just the rows that were selected in the "Select Layer by Attribute" tool. How can I make the "Calculate Field" tool work on just the selections from the preceding tool?
I have been trying to learn VB If-Then statements and Select-Case statements to try to eliminate the "Select Layer by Attributes" portion of the model and simply do it all in the "Calculate Field" tool but my VB skills are basic at best and every time I try I get an error saying "No records within table".
I am using VB code in the "Code Block" window that is the following:
If [DDP_OID.Tim_Permission] = "Yes"
and in the "Expression" portion of the Calculate Field tool I have:
Int ( 2 )
Any help would be absolutely wonderful.
Thanks in advance,
Tom
[ATTACH=CONFIG]28207[/ATTACH]
If [DDP_OID.Tim_Permission] = "Yes" Then Output = 2 Else Output = [Parcels20120128_1.RuleID] End If
The calculation is structured incorrectly for VB. It needs to be like this:
Expression: Output
Code Block (Optional):If [DDP_OID.Tim_Permission] = "Yes" Then Output = 2 Else Output = [Parcels20120128_1.RuleID] End If
This will only overwrite the Parcel20120128_1.RuleID with 2 when the value of DDP_OID.Tim_Permission is "Yes". Otherwise it will just write the current value of Parcel20120128_1.RuleID into itself unchanged. Then even if the records were not selected they will only be changed when the condition is met.
You must always provide an output value for every record the calculation might process, even if all you want to do is leave the value of the calculated field unchanged for some of those records.
If [DDP_OID.Tim_Permission] = "Yes" Then Output = 2 Else Output = [Parcels_20130128_1.RuleID] End If
Then Output = Int ( 2 )and see what happens...
Ok. In the field that I'm doing the "Select Layer by Attributes" there are a significant amount of rows that are <null>. I'm going to eliminate them from the feature class and see. I will be posting later today with more screenshots and such. Do you know if I can post actual feature classes, .mxd files, etc. on here or are those attachments not allowed?
thanks for your ongoing help.
td