两个MS Access数据库字段的总和 [英] sum of two MS Access database fields
本文介绍了两个MS Access数据库字段的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Friends the problem for calculating the sum of two fields is resolved. Thanks to you all but there is one more problem in that:
actually i need to display the sum of these two fields(refund and sub) on a VB6 data report using MS Access database. If there is only one record based on the cretaria (select * from employees where Designation='" & cmbodesig.Text & "') then it is displaying the sum but if there are two or more employees with a particular designation it loops through all but displays the total sum on the report which is creating a problem.
I want like
name designation ref sub total(sum of ref+sub of each employee)
and under these columns i want the individual records
The code which i am trying is
<code>
rs.MoveFirst
Dim cc, xx, tt As Long
cc = rs.Fields(16)
xx = rs.Fields(17)
tt = cc + xx
Do While Not rs.EOF
DataReport2.Sections("Section1").Controls("label16").Caption = tt
rs.MoveNext
Loop
</code>
please help
谢谢
Sarfaraz
Thank you
Sarfaraz
推荐答案
你好朋友
通过查看我的代码找到解决方案
工作的代码是
Hello friends
I find the solution by looking into my code
the code that worked is as
<br />
Set rs = New ADODB.Recordset<br />
rs.Open "select * from employees where Designation='" & cmbodesig.Text & "'", Con, adOpenDynamic, adLockPessimistic<br />
Dim cc, xx, tt As Integer<br />
cc = rs.Fields(16)<br />
xx = rs.Fields(17)<br />
tt = cc + xx<br />
msgbox tt<br />
<br />
谢谢大家。 Ron Beyer和Maciej Los参与我的问题
谢谢
Thank you all esp. Ron Beyer and Maciej Los for their involvement into my question
Thank you
这篇关于两个MS Access数据库字段的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文