BeforeUpdate form event, validation of data

Cait

Registered User.
Local time
Today, 03:28
Joined
Feb 25, 2008
Messages
15
I have a field on which I like to perform some data validation before the record is saved (regardless of either it's an new or existing record).

The logic is this: If Closed is not null, then resolution and notified must not be null (have zero length protection at table level).

My code is as follows on the form BeforeUpdate event:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
  ' Check that resolution and notified have been entered before saving record
    If Not IsNull(Me![Closed]) Then
        If IsNull(Me![Resolution]) Or IsNull(Me![Notified]) Then
            MsgBox "You may not close an item without a resolution and notified method!"
        Cancel = True
        End If
    End If
End Sub

Seems to work ok on initial data entry into the Closed field -- it triggers if Resolution OR Notified is null. However, if you navigate away from the record, come back and delete values from Resolution and navigate away, it doesn't fire. If it's any help, the Resolution field is a memo field.

This doesn't happen with the Notified field (numeric).

Advice or pointers in the right direction would be much appreciated.
 
Possible way is to include the code in your form's OnCurrent_event

JR
 
Hmm, just did a quick and dirty test. Changed Resolution to text(255) instead of memo. The event fired as expected.

So what's up with the memo field that it will allow you to bypass this type of validation?
 

Users who are viewing this thread

Back
Top Bottom