Display message box If

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

My form has a field that either displays the total of several other fields
on the form or if that total exceeds the budget, displays "Exceeds Budget".
If the latter displays, I want a message box to pop up "Can't process
request" and I want the form to clear. I've tried entering the following
code as an After Update event in the next field (I want to give users the
option of changing their entries before the form is cleared), but it's not
working:

If cmb.Total = "Exceeds Budget" Then
MsgBox "Can't process request"
Me.undo
End If

I also tried entering it as an After Update event in the cmbTotal field, but
this didn't work either. What am I missing?

Thanks
 
Use beforeupdate event to stop them from continuing.

Private Sub Text5_BeforeUpdate(Cancel As Integer)

If cmb.Total = "Exceeds Budget" Then
MsgBox "Can't process request"
Cancel = True
End If

End Sub

Hope this helps!
Good luck
 
Thanks, but that didn't work either and then I finally figured out my problem
-- User error -- I had a space before "Exceeds" -- when I changed it to "
Exceeds Budget", it worked!
 
haha... i hate it when that happens!
But BeforeUpdate is a good way to validate their input before you calculate.
 
Back
Top