|
Dim mysqln As String, mymax As Integer
Set rsNum = New ADODB.Recordset
Set rsNumm = New ADODB.Recordset
mysqln = "select max(凭证号) as mymax from 清单 " _
& "where month(日期)=" & Month(Now())
rsNum.Open mysqln, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Label81.Caption = "本月最大编号为" & rsNum!mymax
Set rsNumm = New ADODB.Recordset
mysqln = "select sum(借方金额) as a1,sum(贷方金额) as a2 from 清单 " & "where month(日期)=" & Month(Now())
rsNumm.Open mysqln, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rsNumm!a1 <> rsNumm!a2 Then
凭证编号.Value = rsNum!mymax
Label82.Caption = "不平衡,建议编号为" & rsNum!mymax
ElseIf rsNumm!a1 = rsNumm!a2 Then
凭证编号.Value = rsNum!mymax + 1
Label82.Caption = "平衡,建议编号为" & rsNum!mymax + 1
End If
rsNum.Close
rsNumm.Close
经运行发生这样的问题: 每向 数据表"清单"中添加一记录,就远行一次上述的程序,问题是: 查询出来的最大数"mymax"总是固定,不是最大数,查询出来的其它却是好的,百思不得解,求高手医士!!!!!!!!!!!!!!!!!!! |
|