jushiliren
路人甲
路人甲
  • 注册日期2006-02-07
  • 发帖数2
  • QQ
  • 铜币114枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1776回复:2

vb+mo 查找记录并显示中遇到的问题

楼主#
更多 发布于:2006-05-26 10:26
<P>Dim recSelection As New MapObjects2.Recordset<BR>Dim g_symSelection As New MapObjects2.Symbol<BR>Dim strExpression as String<BR>给strExpression赋值<BR>Set recSelection = map1.Layers(0).SearchExpression(strExpression)<BR>g_symSelection.SymbolType = map1.Layers(0).Symbol.SymbolType<BR>g_symSelection.Color = moRed<BR>map1.FlashShape recSelection.Fields("Shape").Value, 10            闪烁正常<BR>通过map1.Reflash调用map1_AfterLayerDraw()中的<BR>map1.DrawShape recSelection, g_symSelection<BR>出现错误,提示为“要求对象”<BR>另通过msgbox recSelection.Count发现recSelection.Count的值为-1<BR>请问错在何处,如何改正?<BR></P>
喜欢0 评分0
xiaoluxinzi
路人甲
路人甲
  • 注册日期2005-07-16
  • 发帖数5
  • QQ
  • 铜币155枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-07-11 17:31
Set recSelection = map1.Layers(0).SearchExpression(strExpression)<BR>这句写完整MAP1是在哪个FORM里的
举报 回复(0) 喜欢(0)     评分
teeky
路人甲
路人甲
  • 注册日期2003-12-11
  • 发帖数7
  • QQ
  • 铜币94枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-06-21 14:47
<P>又是SearchExpression的问题,MO的SearchExpression,要求的strExpression比较严格且符号与普通的SQL不一样,看看MO的帮助吧:</P>
<P>Set variable = object.SearchExpression( expression)<BR>The SearchExpression method syntax has these parts:</P>
<P>Part Description</P>
<P>variable A variable that has been declared as a Recordset.<BR>object An object expression that evaluates to an object in the Applies To list.<BR>expression A string expression that forms the 'where' clause portion of an SQL statement. Note that MapObjects follows ANSI SQL, not Jet Database Engine SQL. For more information on expression construction, see Remarks below, and the Search Expression Syntax topic.</P>
<P>Remarks</P>
<P>When using SearchExpression, bear in mind that the expression may be parsed and executed within MapObjects, or may be passed to the appropriate daat source for parsing and evaluation. This means you should pay special attention to the syntax according to the data source you are search against. Review the following notes for more information.<BR>Field names and criteria<BR>For more information on how to construct an expression, see the Search Expression Syntax topic.</P>
<P>Enclose criteria by single quotes if the FieldType is moString, e.g. States = 'California'. <BR>Some field names, especially those from ArcInfo Coverage MapLayers, may have dashes in them, e.g. LAYER-ID. This dash may be misinterpreted by the SearchExpression parser. To avoid this, place quotes around field names with dashes, for example:</P>
<P>Set recs = mLyr.SearchExpression("""STATE-ID"" = 24")</P>
<P>Take care when using dates in SearchExpressions. Click here for more detailed information.<BR>If the expression has a length of zero (e.g. the expression string is ""), SearchExpression will return a Recordset containing all of the records in the MapLayer or Table. If your expression was invalid, the Records.EOF property will be True.<BR></P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部