收支数据表
Private Sub Form_AfterUpdate()
Call 总收支计算
Forms(收支记账程序).账户收入 = Nz(DLookup("账户收入", "账户收支查询", "账户名称='" & Forms(收支记账程序).账户名称 & "'"), 0)
Forms(收支记账程序).账户支出 = Nz(DLookup("账户支出", "账户收支查询", "账户名称='" & Forms(收支记账程序).账户名称 & "'"), 0)
Forms(收支记账程序).账户余额 = Forms(收支记账程序).账户收入 – Forms(收支记账程序).账户支出
End Sub
Private Sub 日期_DblClick(Cancel As Integer)
Me.日期 = Date
End Sub
账户收支查询数据表
Private Sub 账户名称_DblClick(Cancel As Integer)
Forms("收支记账程序").Filter = "账户名称='" & 账户名称 & "'"
Forms("收支记账程序").FilterOn = True
Forms("收支记账程序").账户名称.SetFocus
Forms("收支记账程序").账户收入 = Nz(DLookup("账户收入", "账户收支查询", "账户名称='" & Me.账户名称 & "'"), 0)
Forms("收支记账程序").账户支出 = Nz(DLookup("账户支出", "账户收支查询", "账户名称='" & Me.账户名称 & "'"), 0)
Forms("收支记账程序").账户余额 = Forms("收支记账程序").账户收入 – Forms("收支记账程序").账户支出
End Sub
收支记账程序
Private Sub Command生成报表_Click()
DoCmd.OpenReport "账户收支报表", acViewReport, , "账户名称='" & Me.账户名称 & "'"
End Sub
Private Sub Form_AfterUpdate()
Me.账户列表.Requery
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo 数据更新前提醒_Err
If (MsgBox("是否保存对记录的修改", 1, "修改记录提醒") = 1) Then
Beep
Else
DoCmd.RunCommand acCmdUndo
End If
数据更新前提醒_Exit:
' Exit Function
Exit Sub
数据更新前提醒_Err:
MsgBox Error$
Resume 数据更新前提醒_Exit
End Sub
Private Sub Form_Load()
Me.账户收入 = Nz(DLookup("账户收入", "账户收支查询", "账户名称='" & Me.账户名称 & "'"), 0)
Me.账户支出 = Nz(DLookup("账户支出", "账户收支查询", "账户名称='" & Me.账户名称 & "'"), 0)
Me.账户余额 = Me.账户收入 – Me.账户支出
Call 总收支计算
End Sub
模块
Public Sub 总收支计算()
Forms("收支记账程序").总收入 = Nz(DSum("金额", "收支表", "收支='收入'"), 0)
Forms("收支记账程序").总支出 = Nz(DSum("金额", "收支表", "收支='支出'"), 0)
Forms("收支记账程序").总余额 = Forms("收支记账程序").总收入 – Forms("收支记账程序").总支出
End Sub
如若转载,请注明出处:https://www.daxuejiayuan.com/46242.html