OK all, I need a little help. Not sure how simple or how complicated this is. For starters I am a recent GIS graduate but not very proficient with model builder/python/vbscript (yet). I inherited a tool that was written in vbscript. Basically it searches a table, finds the matching information and zooms to the item being searched for. however, as of late, I keep getting a runtime error 91.
This is the code where the error is:
pActiveview.PartialRefresh esriViewGeoSelection, Nothing, Nothing
pfeatureselection.SelectFeatures pqueryfilter, esriSelectionResultNew, False
pActiveview.PartialRefresh esriViewGeoSelection, Nothing, Nothing
No idea what this means. I was hoping for one of two things here:
1) someone can tell me how to fix this
2) there is a way to create simpler tool using model-builder
Thanks in advance for any help received!!
-Joe
Hi Joe,
Thanks for the information so far.
To answer both of your questions, we would probably need more information, namely the code the tool is using. Also if you could give us the full wording of the error code you are getting, that can help define what is causing the error.
Posting Code blocks in the new GeoNet if you need help with posting code to Geonet follow that link, and posting code blocks is generally preferred to uploading a script(unless it is ridiculously long, which it shouldn't from the sound of the tool).
[is there] a way to create simpler tool using model-builder
The way this is done now is in python using the arcpy.mapping module. You can either write a Python script and paste it into the Python window, or write a little Python function in ModelBuilder inside the Calculate Value tool.
VBA (I'm assuming this is a VBA script) is deprecated in ArcGIS 10.1 (you need a special install for it to even run). Python scripts or .NET ArcObjects is the current way to accomplish this kind of thing.
I may add that this functionality is pretty easy out of the box in 10.x: Select Features By Attribute, right click the layer, Selection, Zoom To Selected.
A few things:
- It is VBA Script
- see image below for the error
- I know how to use the select by attributes, but the way this was setup was much easier without having to repopulate the attribute field. This tool searches all the parcels of a county (60,000+) with a menu (see below image)
Did not realize they don't have a syntax formatting for VB.
From MSDN:
There are two steps to creating an object variable. First you must declare the object variable. Then you must assign a valid reference to the object variable using the Set statement.
The only two object variables in the line that you highlighted as the error are pfeatureselection and pqueryfilter so one of these has not been set. Have a look at the code before this line to make sure that both of these variables have been assigned.
However, I would strongly suggest migrating this tool to something other than VBA for the reasons that Curtis has already mentioned.