添加记录和操作记录集以包含公式

发布于 2024-12-20 14:05:28 字数 431 浏览 4 评论 0原文

基本细节: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难得心□动 2024-12-27 14:05:28

我不相信您可以以这种方式使用 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 use application.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 summing rst.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文