dlookup,dcount,dsum,dmax,dmin函數(shù)應用
銷售管理
Private Sub Form_Load()
Me.銷售總額.Value = Nz(DSum("銷售金額", "銷售數(shù)據(jù)表"), 0)
Dim data_count As Long
data_count = Nz(DCount("銷售金額", "銷售數(shù)據(jù)表"), 0)
If data_count <> 0 Then
Me.平均銷售額.Value = CCur(Nz(DSum("銷售金額", "銷售數(shù)據(jù)表"), 0) / data_count)
Else
Me.平均銷售額.Value = 0
End If
Me.最大銷售額.Value = Nz(DMax("銷售金額", "銷售數(shù)據(jù)表"), 0)
Me.最小銷售額.Value = Nz(DMin("銷售金額", "銷售數(shù)據(jù)表"), 0)
End Sub
Private Sub 客戶_Change()
Me.客戶銷售額 = Nz(DLookup("銷售金額合計", "客戶銷售查詢", "客戶='" & Me.客戶 & "'"), 0)
End Sub
銷售數(shù)據(jù)表
Private Sub Form_AfterUpdate()
Forms("銷售管理").銷售總額.Value = Nz(DSum("銷售金額", "銷售數(shù)據(jù)表"), 0)
Dim data_count As Long
data_count = Nz(DCount("銷售金額", "銷售數(shù)據(jù)表"), 0)
If data_count <> 0 Then
Forms("銷售管理").平均銷售額.Value = CCur(Nz(DSum("銷售金額", "銷售數(shù)據(jù)表"), 0) / data_count)
Else
Forms("銷售管理").平均銷售額.Value = 0
End If
Forms("銷售管理").最大銷售額.Value = Nz(DMax("銷售金額", "銷售數(shù)據(jù)表"), 0)
Forms("銷售管理").最小銷售額.Value = Nz(DMin("銷售金額", "銷售數(shù)據(jù)表"), 0)
End Sub