Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am creating a simple text search application, where the user can enter an address search and the result appear in a listbox, which they can then select it and zoom to the address.

Now the problem I am having is that I have set layer definition, within the layer I am working with to only show Residential addresses ( and this works, as i can only see residential addresses in the attribute table), however when I enter a street (in the app), that contains not only residential address, the records appear in my list box when though I have set the layer definition.

Is this behavior normal ? and what is the best way to get round this?


share|improve this question
up vote 1 down vote accepted

It is a normal behaviour.

You can use IGeoFeatureLayer. It will search only within your definition query.

Dim pGeoFtrLyr As IGeoFeatureLayer
Set pGeoFtrLyr = pMap.Layer(0)

Dim pQueryFilter As IQueryFilter
Set pQueryFilter = New QueryFilter
pQueryFilter.WhereClause = "STNAME = 'Stack Street'"

Dim pFtrCur As IFeatureCursor
Set pFtrCur = pGeoFtrLyr.Search(pQueryFilter, False)

Or you can simply set set your QueryFilter to include the Layer Definition Query too.

share|improve this answer
Perfect, thanks! – MapMan Jul 5 '12 at 12:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.