This is the beginning of my Before Update event
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
intReturn = MsgBox("Do you want to save the changes?", vbYesNoCancel)
Select Case Response
Case vbYes
' do nothing
Case vbNo
' Undo the changes before exiting
Me.Undo
Exit Sub
Case vbCancel
' Cancel and return to the form
Cancel = True
End Select
End If
If IsNull([Feedyard]) Then
Msg = "Feedyard Must be Entered"
Style = vbOKOnly + vbCritical
Title = "Feedyard Validation"
Response = MsgBox(Msg, Style, Title)
[Feedyard].SetFocus
Cancel = True
Exit Sub
End If
....theres more validation.
I click the X button to close and if I choose no don't save...I exit the form just fine. If I choose to save the record I get I get the Feedyard must be entered message, when I click OK then I get this error.
"Can't more the focus to the control Feedyard. Runtime error 2110!
If I take the set focus out then it gives the message that it can't save this record. It's as if it is not seeing the cancel=True.