Alternative is to not make the checkbox available until there is a value in date field. Set the checkbox Visible or Enabled property to No.
I thought about that, but knowing our users, we would get a ton of people commenting that the check box is not enabled. My thinking is that this way would actually let them know "why" and reduce the redundant questions we get.
I still may go this route if I cannot get it to do what I want.
Why even have the checkbox? The date field is a flag that client is 'terminated' - no date means not terminated, date means terminated. If the checkbox is to distinguish between a termination as opposed to transfer, there is no way to know that the action is a termination if user neglects to check the box - results in GIGO (garbage in, garbage out) syndrome.
A few reasons. Here is the most important.
Near the end of the plan year, they will start to generate annual (2014) records for next year. If they know a client is terminating at the end of the year, they can enter a date of 12/31/2013. Then when they go to create records for 2014, records will not be created for that group. However, once they check the Terminated Client check box, the group is removed from all functionality and reports. They obviously do not want to do that until the end of the plan year has passed.
Don't issue the UNDO. Just the Cancel = True will be enough.
Tried that already, and that's rather clunky. It leaves the record in "write" mode, and the message box keeps popping up no matter where you click until you hit the ESC button. So if the users don't now enough to do that, they will be caught in a frustrating loop.
However, you replies got me thinking about different ways of approaching this, and I think it got it to work like I want using the AfterUpdate event instead. It has the desired/intended affect.
Basically, instead of trying to prevent the check box selection beforehand, it is just changing it back afterwards (right away).
Code:
Private Sub ysnTermPlan_AfterUpdate()
' If Term Date field is blank, remove check box
If (Me.ysnTermPlan = True) And (Nz(Me.dteTermDate, DateValue("12/31/2099")) = DateValue("12/31/2099")) Then
Me.ysnTermPlan = False
MsgBox "You cannot check the Terminated Plan box without first filling out the Term/Transfer Date field!", vbOKOnly, "ATTENTION!!!"
End If
End Sub