Using Select Layer by Attributes and Calculate Field together in Model Builder

5905
11
Jump to solution
10-09-2013 02:11 PM
ThomasDark
New Contributor
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]
0 Kudos
11 Replies
RichardFairhurst
MVP Honored Contributor
So it worked once, but now it's giving me the Warning again.  I"m going to get it but thought I'd update you.  If I need to I'll post Join info and we'll go through it.

td


If the problem is with Nulls then the calculation should be revised as follows in the codeblock section:

If IsNull([DDP_OID.Tim_Permission]) Then
  Output = [Parcels20120128_1.RuleID]
Else
  If [DDP_OID.Tim_Permission] = "Yes" Then
    Output = 2
  Else
    Output = [Parcels20120128_1.RuleID]
  End If
End If
0 Kudos
desalas
New Contributor II

I have found that when I get an empty set warning it is because the selecting set falls outside of the current extent in the environments settings. 

0 Kudos