As @Geoist said, the 2nd option that you had looks the best. It took me a bit to figure out the oddity in the code though. There are a couple of things going on.
- Turns out you are mixing code types. The
.startswith() function is Python. The rest of what you were doing was VBScript. To accomplish the same thing, you would want to use the InStr functions, of
- Depending on what version of ArcGIS you are using, there may be an issue with the way you declared your variables. If you are using ArcGIS 10 or newer, then take a look at the relevant help file that discusses Field Calculator Examples. The salient point is that:
VBScript does not allow you to explicitly declare any data types; all variables are implicitly Variant. Statements like Dim x as String should be removed or simplified to Dim x.
So, where you defined your two variables as
String, they would need to be simply defined as
Dim hyplink and
Here is a VBScript code sample that does what you are looking for:
asbuilt = [Asbuilt]
If left(asbuilt,2) = "WL" then
hyplink = "Water Info\Water AsBuilt Scans\City_Waterlines_WL\" & asbuilt
hyplink = [Hyperlink]
If you want to use Python, try this code sample instead:
hyplink = "Water Info\Water AsBuilt Scans\City_Waterlines_WL\" + asbuilt
hyplink = hyperlink
Please note that there are major differences in syntax between the VBScript and the Python languages. Please refer to the Field Calculator link above for some basic information, or go here for more detailed information on Python: Python
Hope this helps!