大家好 请问一下如何将数组大小设置为记录集中某一列非重复值的计数呢?非常感谢例如,我是这么写的:
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) 的值) 那么应该怎么办呢
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) 的值) 那么应该怎么办呢
后来g.cn了一下 “!”和“.”的区别 没太看明白 能稍微细说一下吗?非常感谢
rs!字段名称
rs.fields(item)
rs.fields("字段名称")
rs(item)
rs("字段名称")
都是可以的,只是我喜欢用!因为打字最少,呵呵....