PDA

View Full Version : Two Message Box Displays



hdevadiga
02-28-2011, 09:34 PM
Hi Friends,

Myself Hari having a problem while playing with this textbox code of mandatory field....

Private Sub txtDOI_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Me.txtDOI
If txtDOI.Text Like "" Then
MsgBox "DATE OF INCIDENT SHOULD NOT BE LEFT BLANK"
Cancel = True
txtDOI.SetFocus
txtDOI.SelStart = 0
End If
End With
End Sub

Above mention code given me a proper output but it showing the message box alert two time.. First time when i run above mentioned code that one is fine.. Second time when i close the userform i get a same message box and i dont want that second time once....

Can any one help in this.....

mdmackillop
03-01-2011, 05:57 PM
Try using the BeforeUpdate event, rather than Exit.