- XFM attribute query (Feature Query VBA)

The attached macro provides an alternate method of searching and locating XFM features.  This simple yet customizable search option may be a good alternative to using the generic and complex capabilities offered by OpenCities Map's Query tool.



  1. Download and place the MVBA in the folder pointed to by MS_VBASEARCHDIRECTORIES.
  2. Add the following line to the CFG file of the XFM workspace to load the VBA at startup:  MS_VBAUTOLOADPROJECTS > xfmFeatureQuery
  3. The Feature Query tool looks for query files in the MS_GEOWSHOME\qry folder.  Create qry folders for each XFM workspace using this tool.



The Feature Query tool uses customizable query files (*.QRY) to define searches and may include such items as the feature table to use, the attribute name, the title of the search and so on.  A template is provided showing the supported parameters.


A sample design file and queries are provided.   The design file contains parcels, addresses and communications data for a few city blocks.




The following example performs a query on a single property:


The following example queries two properties from the same table.  In this case, the street name and house number:



When the Feature Query tool is configured for the active workspace of a OpenCities Map or OpenCities  Map based tool (OpenUtilities Designer, OpenUtilities Comms, etc), it can be started with the following key in:  vba run [xfmFeatureQuery]OpenDialog

This keyin can be added to a custom button or a function key for quick access.

When started, the Feature Query dialog will open and list the available queries found in MS_GEOWSHOME\qry  folder.  

If the macro does not find a location with query files, it will abort with an error message and not open the dialog.

Select one of the available query options.  In single property mode, the Feature Query dialog changes to show a second property list containing the available property values and a de-activated search button.


In dual property mode, the dialog shows a second property list containing the available property values as well as a de-activated third option list and search button.


Note that you can switch from one search query to the next.

Select the property or properties to search.

In single property mode, the selected property will activate the Search button.

In dual property mode, the first selection will activate the next option list.  A selection in the next option list will then activate the search button.


Click the Search button to execute the search.  When a single feature is found, the Feature Query tool will select and zoom to the feature in the active view.


When multiple features are found, the Feature Query tool will load the results into the Data Browser for further exploration.

 Note that the Feature Query tool is modeless which allows you to keep the dialog open and execute multiple queries during your design session.



You have the option to specify language specific titles and label parameters in the query files.

The Feature Query tool checks the operating system for the language defined in the regional settings.  Based on that setting, it will try to load a string in the appropriate language.  Currently, English (=default) and German strings are included.



The Feature Query tool has the following known limitations.

  1. Only XFM data residing in the open file or attached reference files are supported. 
  2. Database (spatial) queries are not supported
  3. This tool can be slow when working with a large dataset or reference files.
  4. A combo box can only hold 65,535 items.  If the list contains more than this, it will be truncated


Disclaimer - This application is supplied as-is and does not come with support. Bentley Systems Inc., and the author of this programs assume no liability for damages direct, indirect, or consequential, which may result from the use of this program. Use this application at your own risk.