How to perform an attribute query


This example will demonstrate how to execute an attribute query.

How to use

  1. Paste the code into your VB6 or VBA Application.
  2. Call the function from within your application.
[VBA]
Public Function AttributeQuery(pTable As esriGeoDatabase.ITable, _
                               Optional whereClause As String = "" _
                               ) esriGeoDatabase.ICursor
    
    Dim pQueryFilter As esriGeoDatabase.IQueryFilter
    Dim pCursor As esriGeoDatabase.ICursor
    ' create a query filter
    Set pQueryFilter = New esriGeoDatabase.QueryFilter
    
    ' create the where statement
    pQueryFilter.whereClause = whereClause
    
    ' query the table passed into the function and use a cursor to hold the results
    Set pCursor = pTable.Search(pQueryFilter, False)
    
    Set AttributeQuery = pCursor
    
End Function