How do I pass a variable name - as the variable, not its name as a string - in a VB codeblock when calculating a field in ArcPy?
I am using field calculator in a tool I built with Model Builder to replace null values in one field of a feature class with 0, using a VB code block. It works as expected when I run the tool.
The field name is a string variable: Count_DATE where I update DATE in the field name daily.
When I export and run the tool from a Python script, there's an issue with the variable of the field name in the VB codeblock.
Count_DATE = "Count_DATE"
fc = Count_by_area
arcpy.CalculateField_management(fc, "%Count_DATE%", "Output", "VB", "If IsNull([%Count_DATE%]) Then Output = 0 Else Output = [%Count_DATE%] End If ")
I tried removing the %
and []
but am not sure how to deal with the entire code block being within quotation marks.