T
Tony Williams
I have a form that includes a tab control. I want to check that the total in
a control on page 3 of the tab control agrees with the total of another
control on page 2 when the form is closed. I have the following code in the
Before Update event of the total on page 3
Private Sub txtAdvTot_BeforeUpdate(Cancel As Integer)
If ([txtAdv0] + [txtAdv500] + [txtAdv1000] + [txtAdv5000] + [txtAdv10000] +
[txtAdv50000] + [txtAdv100000]) <> [txtAdvTot] Then
If MsgBox(" Column 1 does not add up" & vbCrLf & "It should be " & [txtAdv0]
+ [txtAdv500] + [txtAdv1000] + [txtAdv5000] + [txtAdv10000] + [txtAdv50000]
+ [txtAdv100000] & " - Do you want to accept the error?", vbYesNo,
"Calculation Error") = vbNo Then
Cancel = True
If ([txtAdv0] + [txtAdv500] + [txtAdv1000] + [txtAdv5000] + [txtAdv10000] +
[txtAdv50000] + [txtAdv100000]) <> [txtAdvancessole] +
[txtAdvancesassetssole] + [txtAdvancesothersole] + [txtAdvancesassetspart] +
[txtAdvancesotherpart] + [txtAdvancespart] + [txtAdvancespartnp] +
[txtAdvancesassetsnp] + [txtAdvancesothernp] Then
If MsgBox(" The total of advances on Page 3 does not equal the total of
advances on Page 2" & vbCrLf & "It should be " & [txtAdv0] + [txtAdv500] +
[txtAdv1000] + [txtAdv5000] + [txtAdv10000] + [txtAdv50000] + [txtAdv100000]
& " - Do you want to accept the error?", vbYesNo, "Calculation Error") =
vbNo Then
Cancel = True
End If
End If
End If
End If
End Sub
However when I close the form with errors I don't get the error message. can
anyone see what I am doing wrong?
a control on page 3 of the tab control agrees with the total of another
control on page 2 when the form is closed. I have the following code in the
Before Update event of the total on page 3
Private Sub txtAdvTot_BeforeUpdate(Cancel As Integer)
If ([txtAdv0] + [txtAdv500] + [txtAdv1000] + [txtAdv5000] + [txtAdv10000] +
[txtAdv50000] + [txtAdv100000]) <> [txtAdvTot] Then
If MsgBox(" Column 1 does not add up" & vbCrLf & "It should be " & [txtAdv0]
+ [txtAdv500] + [txtAdv1000] + [txtAdv5000] + [txtAdv10000] + [txtAdv50000]
+ [txtAdv100000] & " - Do you want to accept the error?", vbYesNo,
"Calculation Error") = vbNo Then
Cancel = True
If ([txtAdv0] + [txtAdv500] + [txtAdv1000] + [txtAdv5000] + [txtAdv10000] +
[txtAdv50000] + [txtAdv100000]) <> [txtAdvancessole] +
[txtAdvancesassetssole] + [txtAdvancesothersole] + [txtAdvancesassetspart] +
[txtAdvancesotherpart] + [txtAdvancespart] + [txtAdvancespartnp] +
[txtAdvancesassetsnp] + [txtAdvancesothernp] Then
If MsgBox(" The total of advances on Page 3 does not equal the total of
advances on Page 2" & vbCrLf & "It should be " & [txtAdv0] + [txtAdv500] +
[txtAdv1000] + [txtAdv5000] + [txtAdv10000] + [txtAdv50000] + [txtAdv100000]
& " - Do you want to accept the error?", vbYesNo, "Calculation Error") =
vbNo Then
Cancel = True
End If
End If
End If
End If
End Sub
However when I close the form with errors I don't get the error message. can
anyone see what I am doing wrong?