Table & form validation rules can be set at the table level or form level. Use the power of the database to manage your form validation. Why spending time coding something that the database can already handle for you?
Remember that a validation rule created at the table level is available to all the forms and reports in your database. The validation rule created at the form level is for that form only.
Watch the video:
Here is a handy Table & Form Validation Rule reference chart:
|Validation Rule||Tests For||Validation Text|
|<>0||Whether or not the value entered is different from 0||“Please enter a non-zero value.”|
|0 or >100||Whether the value entered is 0, or greater than 100.||“The value entereed must be either 0 or over 100”|
|Like “K???”||Whether or not the value entered is 4 characters long, and begins with the letter K.||“The value of your entry must begin with the letter K and be 4 letters long.”|
|< #2/12/2007#||Whether or not the date entered falls before 2/12/2007.||“The value of your entry must be before 2/12/2007.”|
|Between 0 And 1||Whether or not the value entered is between 0 and 1.||“Please enter a percentage amount from 0 to 100%”|
Default values are another way of validating data entry. By having a default value, new records are automatically populated with required information.
Making a field entry “Required” is another method of making sure the user doesn’t skip entering a value in a field.
The video shows some fields with built in form validation. Fields like:
The check box
The combo box
The option group
The list box
Then various ActiveX Controls
These controls limit the user to the given selections. Any time you limit the selection to the user, you are enforcing validation.
Here is the code I used:
Option Compare Database
Private Sub btnSelect_Click()
Select Case Me.Frame0
Private Sub Calendar1_Click()
Private Sub Form_Current()
Me.Calendar1.Value = Now()