添加记录和操作记录集以包含公式
基本细节: oracle、vb6 和 excel,使用 ADO 获取记录集。
当我在记录集末尾添加新记录时,我在操作记录集时遇到问题。最后一条记录应包含公式,例如列 2 的计数、列 3 中值的总和以及
记录集中 sum(col3) 和 col2 原始列的除法
此列的 CLIENT 末尾应显示 Total
PRINCIPAl 此列的末尾应显示 average(Principal)
当我添加记录集时,此列的
GROSS_LIQ_RATE 末尾应显示average(gross)/sum(principal),但会出现错误 我是这样添加的:
.AddNew .[columnname] = Sum(rst.Fields(1)) .Update
感谢您对此进行调查。
basic details:
oracle, vb6 and excel, using ADO to fetch recordsets.
I am facing a problem in manipulating the recordset when i add a new record at the end of the recordset. the last record should contain the formulas such as count of, say, column2, sum of values in column3, and division of sum(col3) and col2
original columns in recordset
CLIENT end of this column should display Total
PRINCIPAl end of this column should display average(Principal)
GROSS_LIQ_RATE end of this column should display average(gross)/sum(principal)
when I am adding the recordset, it gives an error
i am adding like this:
.AddNew .[columnname] = Sum(rst.Fields(1)) .Update
thanks for looking into this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信您可以以这种方式使用
Sum()
。您将使用application.worksheetfunction.sum()
因为 sum 不是 vba 函数。其次,我认为 rst.fields(1) 不会返回该字段中的所有值。您需要迭代记录集,对每条记录求和 rst.fields(1).value 。
从设计的角度来看......您正在寻找的所有值都可以直接通过 SQL 轻松计算,我看不出有任何理由将数据拉入记录集来执行这些操作。
I don't beliveve you can use
Sum()
in that way. You would useapplication.worksheetfunction.sum()
since sum is not a vba function.Secondly I don't think
rst.fields(1)
will return all values in the field. You would need to iterate through the recordset summingrst.fields(1).value
for each record.From a design standpoint.... all of the values you are looking for could easily be calculated via SQL directly, I don't see any reason for pulling the data into a recordset to preform these operations.