DataChanged Property and Validate Event Example

The example illustrates simple data validation.  In the Authors table in the BIBLIO.MDB database, there are two fields: Au_ID and Author.  Since the value in Au_ID is used to uniquely identify the author, this value should not change.  The example does not allow changes to the Au_ID field, which is bound to Text1.

Sub Data1_Validate (Action As Integer, Save As Integer)
  If Text1.DataChanged Then              ' Check for change in data.
    MsgBox "You can't change the ID number."
    Text1.DataChanged = False            ' Do not save changed data.
  End If
End Sub