AlanJordan
Programmer
I have a report that uses groups to create subtotals of each group.
At the end of the report, I have a grand total.
I want to calculate the percentage of each subtotal of the grand total.
I tried the following code, which fails because Access will not allow me to set the focus and it will not allow the assignment with having the focus set.
Interestingly, the function worked once, and then did not work. Perhaps I was in break mode that first time.
Any insights or suggestions will be appreciated.
At the end of the report, I have a grand total.
I want to calculate the percentage of each subtotal of the grand total.
I tried the following code, which fails because Access will not allow me to set the focus and it will not allow the assignment with having the focus set.
Interestingly, the function worked once, and then did not work. Perhaps I was in break mode that first time.
Any insights or suggestions will be appreciated.
Code:
Function CalcGroupPercentage()
On Error GoTo err_CGP
Dim dblNumerator As Double
Dim dblDenominator As Double
Report_rptTimeInvested.txtGroupSubtotal.SetFocus
dblNumerator = CDbl(Me.txtGroupSubtotal.Text)
Me.txtGrandTotal.SetFocus
dblDenominator = CDbl(Me.txtGrandTotal.Text)
If dblDenominator <> 0 Then
CalcGroupPercentage = dblNumerator / dblDenominator
Else
CalcGroupPercentage = 0
End If
Exit Function
err_CGP:
ErrBox
End Function