Hello,
I'm tryng to populate a field with this VBA code but it doesn't work. I really appreciate any help you can provide.
Dim codigo as string
If [CAMPO]="Captura" OR [CAMPO]="Replanteo" OR [CAMPO]="GPS" Then
codigo = "1"
ElseIf [CAMPO]="Plano" OR [CAMPO]="Ortofoto" Then
codigo = "2"
ElseIf [CAMPO]="Catastro" OR [CAMPO]="Ajuste parcelario" Then
codigo = "3"
Else codigo = [CAMPO]
EndIf
__esri_field_calculator_splitter__
codigo
Hi alaska@pozo,The only thing I see in your code it the "Else codigo = [CAMPO]" being on 1 line, but changing it doesn't solve the problem. What you can do is change your code and use a Select Case. This simplifies the code and seems to work (at least for me in 10.2):Select Case [CAMPO]
Case "Captura", "Replanteo", "GPS"
codigo = "1"
Case "Plano", "Ortofoto"
codigo = "2"
Case "Catastro","Ajuste parcelario"
codigo = "3"
Case Else
codigo = [CAMPO]
End Select
__esri_field_calculator_splitter__
codigo
Hope this works for you too.Kind regards,XanderBTW: since this is the Python forum, you could consider using the Python syntax:
def ClfyCampo(campo):
if campo == "Captura" or campo == "Replanteo" or campo == "GPS":
return "1"
elif campo == "Plano" or campo == "Ortofoto":
return "2"
elif campo == "Catastro" or campo == "Ajuste parcelario":
return "3"
else:
return campo
__esri_field_calculator_splitter__
ClfyCampo( !CAMPO! )