源代码在这儿:
Sub bijiao(t1 As Long, t2 As Long, zu As String)
Dim panduan As Boolean, temp As Double
hzong = 0
nnn = 0
zong = 0
With huikuan
If .Recordset.EOF = True And .Recordset.BOF = True Then
Exit Sub
End If
.Recordset.MoveFirst
Do Until .Recordset.EOF
If Val(.Recordset("日期")) >= t1 And Val(.Recordset("日期")) <= t2 And .Recordset("组别") = zu Then
panduan = False
hbaobiao.Refresh
nnn = nnn + 1 '设置全部记录数计数器
zong = zong + .Recordset("回款额") '统计所有符合条件的记录的回款额
hzong = hzong + .Recordset("回款额")
'假如数据库为空,则进行添加
If hbaobiao.Recordset.EOF = True And hbaobiao.Recordset.BOF = True Then
Call cunru
GoTo aaa
Else
'对已有数据进行判断,以决定是否添加数据,还是进行数据更新
hbaobiao.Recordset.MoveFirst
Do Until hbaobiao.Recordset.EOF
'---------------------------------------------------------------------------
'就是这一段被跳过
If hbaobiao.Recordset("单位名称") = .Recordset("单位名称") _
And hbaobiao.Recordset("组别") = .Recordset("组别") Then
temp = hbaobiao.Recordset("回款额")
hbaobiao.Recordset.Delete
hbaobiao.Recordset.Close
hbaobiao.Recordset.Open
hbaobiao.Refresh
hbaobiao.Recordset.AddNew
hbaobiao.Recordset("类型") = .Recordset("类型")
hbaobiao.Recordset("组别") = .Recordset("组别")
hbaobiao.Recordset("单位名称") = .Recordset("单位名称")
hbaobiao.Recordset("回款额") = .Recordset("回款额") + temp
hbaobiao.Recordset.Update
panduan = True
hbaobiao.Recordset.MoveNext
Else
hbaobiao.Recordset.MoveNext
End If
'-------------------------------------
Loop
If panduan = False Then
Call cunru
End If
End If
aaa:
.Recordset.MoveNext
Else
.Recordset.MoveNext
End If
Loop
End With
End Sub
Sub bijiao(t1 As Long, t2 As Long, zu As String)
Dim panduan As Boolean, temp As Double
hzong = 0
nnn = 0
zong = 0
With huikuan
If .Recordset.EOF = True And .Recordset.BOF = True Then
Exit Sub
End If
.Recordset.MoveFirst
Do Until .Recordset.EOF
If Val(.Recordset("日期")) >= t1 And Val(.Recordset("日期")) <= t2 And .Recordset("组别") = zu Then
panduan = False
hbaobiao.Refresh
nnn = nnn + 1 '设置全部记录数计数器
zong = zong + .Recordset("回款额") '统计所有符合条件的记录的回款额
hzong = hzong + .Recordset("回款额")
'假如数据库为空,则进行添加
If hbaobiao.Recordset.EOF = True And hbaobiao.Recordset.BOF = True Then
Call cunru
GoTo aaa
Else
'对已有数据进行判断,以决定是否添加数据,还是进行数据更新
hbaobiao.Recordset.MoveFirst
Do Until hbaobiao.Recordset.EOF
'---------------------------------------------------------------------------
'就是这一段被跳过
If hbaobiao.Recordset("单位名称") = .Recordset("单位名称") _
And hbaobiao.Recordset("组别") = .Recordset("组别") Then
temp = hbaobiao.Recordset("回款额")
hbaobiao.Recordset.Delete
hbaobiao.Recordset.Close
hbaobiao.Recordset.Open
hbaobiao.Refresh
hbaobiao.Recordset.AddNew
hbaobiao.Recordset("类型") = .Recordset("类型")
hbaobiao.Recordset("组别") = .Recordset("组别")
hbaobiao.Recordset("单位名称") = .Recordset("单位名称")
hbaobiao.Recordset("回款额") = .Recordset("回款额") + temp
hbaobiao.Recordset.Update
panduan = True
hbaobiao.Recordset.MoveNext
Else
hbaobiao.Recordset.MoveNext
End If
'-------------------------------------
Loop
If panduan = False Then
Call cunru
End If
End If
aaa:
.Recordset.MoveNext
Else
.Recordset.MoveNext
End If
Loop
End With
End Sub
解决方案 »
- 进入一窗体后,窗体不停的抖动是怎么回事,单步执行时正常.
- 偷偷地进来,打枪地不要,可怜偶的小猫,下了整整一夜.
- 为什么对statusbar使用active skin 改变样式时,状态栏文字有时候显示,有时候不显示?
- 请问如何使用commondialog实现保存和另存为的功能,非常感谢!!
- 我要考初级程序员——请指点
- 请教各位高手,我这个该怎么弄呢?
- 最小化时的问题?
- 從sql7.0導出表產生excel檔的問題
- 一个程序调用的问题
- 关于:请问大虾如何用VB的INET控件调用FTP服务器
- 各位,我遇到一个很简单的数据库问题,但我就是搞不定,大家帮我看一看!
- 如何实现MSFlexGrid的单元格显示多行字符
if hbaobiao.recordset.recordcount>0 then
haobiao.recordset.movelast
haobiao.recordset.movefirst
end if
就行了
hbaobiao.Recordset.MoveFirst
和
Do Until hbaobiao.Recordset.EOF
之间加doevents 或 加上一个空循环!
...
loopdo
...
loop until 条件
hbaobiao.Recordset.Close
hbaobiao.Recordset.Open
这几句话放在循环里面也有问题
改为;
while 语句试一下!
在调试环境下系统会认为正确的