Validate Event

See AlsovbevtValidateSee                 ExamplevbevtValidateEx>Low

Applies To

Data control2E1FEX3.

Description

The Validate event occurs before a different record becomes the current record1BNJB8X; before the Update method (except when data is saved with the UpdateRecord method); and before a Delete, Unload or Close operation.

Syntax

Sub datacontrol_Validate ([ Index As Integer,] Action As Integer, Save As Integer)

Remarks

The Index part uniquely identifies a control if it is in a control array8G7Y0UU.

The Action part indicates the operation that is causing this event to occur.  The possible constants and values of Action are:

Constant                                  Value    Description

 

DATA_ACTIONCANCEL                0      Cancel the operation when the Sub exits.

DATA_ACTIONMOVEFIRST          1      MoveFirst method.

DATA_ACTIONMOVEPREVIOUS  2      MovePrevious method.

DATA_ACTIONMOVENEXT           3      MoveNext method.

DATA_ACTIONMOVELAST           4      MoveLast method.

DATA_ACTIONADDNEW               5      AddNew method.

DATA_ACTIONUPDATE                6      Update operation (not UpdateRecord).

DATA_ACTIONDELETE                7      Delete method.

DATA_ACTIONFIND                      8      Find method.

DATA_ACTIONBOOKMARK          9      The Bookmark property has been set.

DATA_ACTIONCLOSE                  10     The Close method.

DATA_ACTIONUNLOAD                11     The form is being unloaded.

 

These constants and values are in the Visual Basic file CONSTANT.TXT.

You can change the Action part to convert one action into another.  You can change the various Move methods and AddNew, which can be freely exchanged (any Move into AddNew, any Move into any other Move, or AddNew into any Move).  When in AddNew mode, you can use MoveNext and then execute another AddNew to examine the EditMode property to determine if an Edit or AddNew operation is in progress.  Attempting to change AddNew or one of the Moves into any of the other actions is either ignored or produces a trappable error.  Any action can be stopped by setting Action to 0.

The Save argument initially indicates whether bound data has changed (True/False).  Save can still be False if data in the copy buffer is changed.  If Save is True when this event exits, the Edit and UpdateRecord methods are invoked.  Only data from bound controls or from the copy buffer where the DataChanged property is True are saved by the UpdateRecord method.

This event occurs even if no changes have been made to data in bound controlsLVLJ7W, and even if there are no bound controls.  You can use this event to change values and update data as necessary.  You can also choose to save data or not, and choose to stop whatever action is causing the event to occur and substitute a different action.

In your code for this event, you can check the data in each bound control where DataChanged is True.  You can then set DataChanged to False to avoid saving that data in the database.

You cannot use any methods (such as MoveNext) on the underlying Dynaset object during this event.