I have a form where the user has to enter numbers in four fields. If we assume these number fields to be a, b, c and d. But I need to ensure (b-a) is higher than (d-c). So after update of the last input filed, I wrote the following vba:
Dim a,b,c,d As Double
If (d - c) > (b - a) Then
MsgBox "Check your values", vbInformation, "Oops...Wrong figure"
End If
field.SetFocus
This will do the trick. And the curser remains in the filed. But the user can still save the form after clicking the OK button from the msgbox. Is there any way I can add a code that prevent the user from save/close the form without entering the correct number.
Dim a,b,c,d As Double
If (d - c) > (b - a) Then
MsgBox "Check your values", vbInformation, "Oops...Wrong figure"
End If
field.SetFocus
This will do the trick. And the curser remains in the filed. But the user can still save the form after clicking the OK button from the msgbox. Is there any way I can add a code that prevent the user from save/close the form without entering the correct number.