Validating data entry

If you cancel the Validating event, the data will not be synchronized with the data source.Important If you have custom validation that takes place after the Validating event, it will not affect the data binding.In the Validating event-handling method, you can validate user input in several ways.

If only a short range of dates is valid, such as yesterday, today and tomorrow, you can create a drop down list of those dates.

By using formulas, the drop down list will be dynamic, and will show the correct dates whenever the workbook is opened.

When users enter data into your application, you may want to verify that the data is valid before your application uses it.

You may require that certain text fields not be zero-length, that a field be formatted as a telephone number or other type of well-formed data, or that a string not contain any unsafe characters that could be used to compromise the security of a database.

For example, if you have code in a Validated event that attempts to cancel the data binding, the data binding will still occur.

In this case, to perform validation in the Validated event, change the control's Data Source Update Mode property (under (Databindings)\(Advanced)) from On Validation to Never, and add So when does a control's data get validated? You can use either implicit or explicit validation, depending on the needs of your application.On another sheet in the workbook, you'll create a list of valid dates.In this example, the sheet with the list is named Admin Lists.For a code example that validates an email address in a Text Box, see Validating.Validation is very useful when you have bound your controls to a data source, such as a database table.The implicit validation approach validates data as the user enters it.

Tags: , ,