You were right, the null values were causing the issue. I've settled with the following code:
Code:
Private Sub OrderComplete_Click()
' prompt user to amend Order Value if total invoices <> Order Value
Dim Response As String
If OrderComplete.Value = True And OutstandingInvoices < 0 Then
Response = MsgBox("Total invoices exceed Order Value" & vbCrLf & vbCrLf & "Amend Order Value and close order?", VbMsgBoxStyle.vbOKCancel)
If Response = vbOK Then
OrderValue = Nz(Invoice1) + Nz(Invoice2) + Nz(Invoice3) + Nz(Invoice4) + Nz(Invoice5)
ElseIf Response = vbCancel Then
Undo
End If
ElseIf OrderComplete.Value = True And OutstandingInvoices > 0 Then
Response = MsgBox("Total invoices less than Order Value" & vbCrLf & vbCrLf & "Amend Order Value and close order?", VbMsgBoxStyle.vbOKCancel)
If Response = vbOK Then
OrderValue = Nz(Invoice1) + Nz(Invoice2) + Nz(Invoice3) + Nz(Invoice4) + Nz(Invoice5)
ElseIf Response = vbCancel Then
Undo
End If
End If
End Sub
The multiple invoice fields are still not ideal and the code does save calculated data into the table but it doesn't seem to be causing any issues. I'll try and tidy it up more when I have a bit more time to spend on it.
Cheers