Article ID: 129096
Article Last Modified on 1/19/2007
Field/Expression: OrderID
Group Header: Yes
Group Footer: Yes
Name: Extended Price
ControlSource: =[UnitPrice] * [Quantity]
Name: Order Total
ControlSource: =Sum([UnitPrice] * [Quantity])
Name: Report Total
ControlSource: =Sum([UnitPrice] * [Quantity])
Name: Freight
ControlSource: =IIf(Sum([UnitPrice]*[Quantity])>100,0.05*Sum([Unit _
Price]*[Quantity]),0)
Name: FreightRunSum
ControlSource: =IIf(Sum([UnitPrice]*[Quantity])>100,0.05*Sum([Unit _
Price]*[Quantity]),0)
RunningSum: Over Group
Visible: No
Name: Freight Total
ControlSource: =[FreightRunSum]
Option Explicit
Dim OrderTotal As Double ' Used for group total.
Dim GrandTotal As Double ' Used for report total.
Function CalcProduct (R as Report)
Dim tmpAmount As Double
tmpAmount = R![UnitPrice] * R![Quantity]
' Remember the total for the group.
OrderTotal = OrderTotal + tmpAmount
' Remember the total for the report.
GrandTotal = GrandTotal + tmpAmount
CalcProduct = tmpAmount
End Function
Function InitVars ()
OrderTotal = 0
GrandTotal = 0
End Function
Function GetGroupTotal ()
GetGroupTotal = OrderTotal
' Reset the variable to 0 for next group.
OrderTotal = 0
End Function
Function GetReportTotal ()
GetReportTotal = GrandTotal
End Function
OnOpen: =InitVars()
Text box 1:
Name: UnitPrice
ControlSource: UnitPrice
Text box 2:
Name: Quantity
ControlSource: Quantity
Text box 3:
Name: TheProduct
ControlSource: =CalcProduct([Report])
Name: GroupTotal
ControlSource: =GetGroupTotal()
Name: ReportTotal
ControlSource: =GetReportTotal()
Keywords: kbfaq kbhowto kbusage KB129096