sreda, 30. december 2009

Microsoft Access: use a validation rule instead of the Required property

When you want to require users to enter a value in a field, a common technique is to set the Required property for the field to Yes (for example tabPerson.Name.Required = Yes). However, when the user is then adding records to the table and neglects to insert value in that field, the build-in error message that appears is not very helpful:

"The field TableName.FieldName cannot contain Null value because the Required property is set to True. Enter a value in this field."

This error message is not appropriate for typical user, whether it is in English or any other language.

Insetead, I use another simple approach when building table properties:
  1. Set Table.Field.Required to No.
  2. Set Table.Field.Validation Rule to Is Not Null.
  3. Set Table.Field.Validation Text to The value in the field is required. Enter a value or select it from the list.
In this way, you can provide more specific information and helpful hints about how to enter the correct data, rather then just a "required" message.

Note. When converting an Access table into SQL Server we must consider this design property (Required) and set this table or field property manuall.

Ni komentarjev:

Objavite komentar