Messagebox code

T

Tony Williams

I have a message box which pops up a message after a check on a total. The
code on the Before Update Event is:
If ([txtDomfacsole] + [txtDomfacpart]) <> [txtDomfactot] Then
MsgBox "Row 1 does not add up" & vbCrLf & "It should be " & [txtDomfacsole]
+ [txtDomfacpart], vbOKCancel, "Calculation Error"
Cancel = True
End If
First Question
However I want the user to be able to accept the error if they wish, at the
moment this code keeps appearing as the user tabs to the next control. How
can I change the code so that the user has the choice as to whether or not
they want to change the data?

Second Question
I have some 14 rows, with totals, on a form where this calculation needs to
check the addition of various controls. I could of course put this code
behind every total but I wondered if there was a way to do this onec using a
module. If so could someone guide thru the creation of the module and what I
would have to put behind each total control.

TIA
Tony Williams
 
G

Guest

If ([txtDomfacsole] + [txtDomfacpart]) <> [txtDomfactot] Then
Response = MsgBox "Row 1 does not add up" & vbCrLf & "It should be " &
[txtDomfacsole] + [txtDomfacpart], vbOKCancel, "Calculation Error"
End If
If Response = vbOK then
'Do whatever when user OKs message
Else
'Do whatever when user cancels message
End If

TomU
 
G

Guest

Thanks Tom I'll try that
Tony

TomU said:
If ([txtDomfacsole] + [txtDomfacpart]) <> [txtDomfactot] Then
Response = MsgBox "Row 1 does not add up" & vbCrLf & "It should be " &
[txtDomfacsole] + [txtDomfacpart], vbOKCancel, "Calculation Error"
End If
If Response = vbOK then
'Do whatever when user OKs message
Else
'Do whatever when user cancels message
End If

TomU


Tony Williams said:
I have a message box which pops up a message after a check on a total. The
code on the Before Update Event is:
If ([txtDomfacsole] + [txtDomfacpart]) <> [txtDomfactot] Then
MsgBox "Row 1 does not add up" & vbCrLf & "It should be " & [txtDomfacsole]
+ [txtDomfacpart], vbOKCancel, "Calculation Error"
Cancel = True
End If
First Question
However I want the user to be able to accept the error if they wish, at the
moment this code keeps appearing as the user tabs to the next control. How
can I change the code so that the user has the choice as to whether or not
they want to change the data?

Second Question
I have some 14 rows, with totals, on a form where this calculation needs to
check the addition of various controls. I could of course put this code
behind every total but I wondered if there was a way to do this onec using a
module. If so could someone guide thru the creation of the module and what I
would have to put behind each total control.

TIA
Tony Williams
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top