khicon73
MIS
- Jan 10, 2008
- 36
I have 2 forms, one for data entry and one for edit. Data Entry form is working fine, all required fields needed to fill in for record to be saved. However, on the edit form...when someone deleted some values on the required fields and hit the closed button on the menu (tool bar), it just closed the form and validate message won't work...
For example:
Private Sub Form_Close()
If IsNull(Me.txtText1) Or (Me.txtText1) = "" Then
MsgBox "[Text1] Cannot be empty. Please Re-enter!"
Me.txtText1.SetFocus
ElseIf IsNull(Me.txtText2) Or (Me.txtText2) = "" Then
MsgBox "[Text2] Cannot be empty. Please Re-enter!"
Me.txtText2.SetFocus
ElseIf IsNull(Me.txtText3) Or (Me.txtText3) = "" Then
MsgBox "[Text3] Cannot be empty. Please Re-enter!"
Me.txtText3.SetFocus
Else
DoCmd.Close
End If
End Sub
Even though I hit OK when the message pop up, but the form still close.
Please help, thanks.
For example:
Private Sub Form_Close()
If IsNull(Me.txtText1) Or (Me.txtText1) = "" Then
MsgBox "[Text1] Cannot be empty. Please Re-enter!"
Me.txtText1.SetFocus
ElseIf IsNull(Me.txtText2) Or (Me.txtText2) = "" Then
MsgBox "[Text2] Cannot be empty. Please Re-enter!"
Me.txtText2.SetFocus
ElseIf IsNull(Me.txtText3) Or (Me.txtText3) = "" Then
MsgBox "[Text3] Cannot be empty. Please Re-enter!"
Me.txtText3.SetFocus
Else
DoCmd.Close
End If
End Sub
Even though I hit OK when the message pop up, but the form still close.
Please help, thanks.