Query

Query performs a query on the objects in a base layer by object type and attribute values. Returns a Selection collection.

Syntax

object.Query( Query, Operation, CaseSensitive, AllowWildcards )

Parameter

Type

Required/

Optional

Default

Description

Query

String

Required

This specifies the query string.

Operation

SrfQueryOperation

Optional

srfQueryOperationNew

This specifies what operation is performed on the returned objects: create a new selection, add to existing selection, remove from existing selection, create a new selection from existing selection.

CaseSensitive

Boolean

Optional

False

This specifies whether text values in the query string are case sensitive

AllowWildcards

Boolean

Optional

True

This specifies whether the * and ? wildcards may be used in the query string.

ExportFilename

String

Optional

""

This specifies the exported file name when Operation = srfQueryOperationExportToFile

ExportFilterId

String

Optional

""

This specifies the exported file FilterId when Operation = srfQueryOperationExportToFile

Remarks

  • See the Query Objects topic for more information on defining the Query string, including syntax, attributes, functions, and wildcards.

  • Only a single base layer can be queried at one time. Use the StartEditing method before and StopEditing method after using the Query method.

  • To use quotes in a string, use two double quotes. ("this string has a ""quoted string"" in it")

Example

This example demonstrates how to query all polygons where the vertex count is less than 20 and the "Primary" attribute value starts with the uppercase letter "N" and return these objects to the variable QuerySelection.

 

Shapes.StartEditing()

 

'Dim QuerySelection As Object

Set QuerySelection = Shapes.Query(Query:="type=""Polygon"" and VertexCount<20 and [Primary]=""N*""", _

Operation:=srfQueryOperationNew, CaseSensitive:=True, AllowWildcards:=True)

 

Shapes.StopEditing()

Used by: Shapes Collection