大家好 请问一下如何将数组大小设置为记录集中某一列非重复值的计数呢?非常感谢例如,我是这么写的:
dim Numberofplan_date as Integer
……
adoRst2.Open "select count(distinct plan_date) as Numberofplan_date from new_orders ", adoCon, adOpenStatic, adLockOptimistic
debug.print Numberofplan_date 
redim arry1(Numberofplan_date-1)
但调试后发现根本没有传值给Numberofplan_date 后来又尝试使用adoRst2.RecordCount 
即adoRst2.Open "select count(distinct plan_date) from new_orders ", adoCon, adOpenStatic, adLockOptimistic
debug.print adoRst2.RecordCount 
redim arry1(adoRst2.RecordCount -1)
发现adoRst2.RecordCount 值为1 (这才弄明白RecordCount是对返回的记录数进行计数 而不是返回count(distinct plan_date) 的值) 那么应该怎么办呢

解决方案 »

  1.   

    redim arry1(adoRst2!Numberofplan_date-1) 
      

  2.   

    恩 非常感谢 我调试过了 用“!”取代“.”是正确的
     
    后来g.cn了一下 “!”和“.”的区别 没太看明白 能稍微细说一下吗?非常感谢
      

  3.   

    只要记住这是表示记录集数据的方法之一就行了:
    rs!字段名称
    rs.fields(item)
    rs.fields("字段名称")
    rs(item)
    rs("字段名称")
    都是可以的,只是我喜欢用!因为打字最少,呵呵....