Thanks Douglas. Am I right in thinking that Error 1 etc are my current
messages and Condition 1 etc are my current if statements? I don't quite
understand how the different error messages are captured. Here is my
current code Could you start me off on the right track?
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim totclients As Integer
Dim totnbr As Integer
Dim totadvances As Integer
Dim totadvances2 As Integer
'Total of clients on page 4
totclients = ([txtClients0] + [txtClients500] + [txtClients1000] +
[txtClients5000] + [txtClients10000] + [txtClients50000] +
[txtClients100000])
'Total of clients on page 3
totnbr = ([txtClientsdomfacsole] + [txtClientsdomfacABLsole] +
[txtClientsdomidsole] + [txtClientsdomidABLsole] + [txtClientsexpsole] +
[txtClientsexpABLsole] + [txtClientsimpsole] + [txtStockfinsole] +
[txtstockfinABLsole] + [txtClientsdomfacpart] + [txtClientsdomfacABLpart]
+ [txtClientsdomidpart] + [txtClientsdomidABLpart] + [txtClientsexppart]
+ [txtClientsexpABLpart] + [txtClientsimppart] + [txtstockfinpart] +
[txtstockfinABLpart])
'Check totals page 3 and 4
If totclients <> totnbr Then
If MsgBox("The Total Number of Clients on Page 4 does not agree with
Total Number of Clients on Page 3" & vbCrLf & "It should be " & [totnbr]
& " - Do you want to accept the error?", vbYesNo, "Calculation Error") =
vbNo Then
Cancel = True
End If
End If
'Check totals page 3 and 5
If [txtIndClientsTot] <> [txtTotNbrClients] Then
If MsgBox("The Total Number of Clients on Page 5 does not agree with
Total Number of Clients on Page 3" & vbCrLf & "It should be " &
[txtTotNbrClients] & " - Do you want to accept the error?", vbYesNo,
"Calculation Error") = vbNo Then
Cancel = True
End If
End If
'Check Advances on page 4 with page 2
totadvances = ([txtAdv0] + [txtAdv500] + [txtAdv1000] + [txtAdv5000] +
[txtAdv10000] + [txtAdv50000] + [txtAdv100000])
totadvances2 = ([txtAdvancessole] + [txtAdvancesassetssole] +
[txtAdvancesothersole] + [txtAdvancesassetspart] + [txtAdvancesotherpart]
+ [txtAdvancespart] + [txtAdvancespartnp] + [txtAdvancesassetsnp] +
[txtAdvancesothernp])
If totadvances <> totadvances2 Then
If MsgBox("The total of advances on Page 4 does not equal the total of
advances on Page 2" & vbCrLf & "It should be " & totadvances2 & " - Do
you want to accept the error?", vbYesNo, "Calculation Error") = vbNo
Then
Cancel = True
End If
End If
End Sub
Many thanks
Tony
Douglas J. Steele said:
What I typically do is have something like the following:
Dim strMessage As String
strMessage = vbNullString
If Condition1 Then
strMessage = strMessage & "Error 1" & vbCrLf
End If
If Condition2 Then
strMessage = strMessage & "Error 2" & vbCrLf
End If
If Condition3 Then
strMessage = strMessage & "Error 3" & vbCrLf
End If
If Len(strMessage) > 0 Then
MsgBox strMessage
Else
MsgBox "Everything's hunky-dory!"
End If
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
I have a form that does a number of verification checks and pops up
message boxes to warn users of the errors and they have a YES/NO choice
as to whether to accept the error or not. These pop up as individual
message boxes but |I was wondering whether it was possible to only have
one message box which showed the relevant errors. For example say I have
5 messages, If all errors occur the message box would show all 5
messages. If only errors 2 and 5 occur the message box would show
message 2 and 5 and so on. The message box would keep appearing with the
relevant messages until all errors are fixed or the user accepts the
errors.
Thanks
Tony