MS Access Validation – PT2

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
        Case 1
            MsgBox &quot;Red&quot;
        Case 2
            MsgBox &quot;Yellow&quot;
            
    End Select
    
End Sub

Private Sub Calendar1_Click()
    MsgBox Me.Calendar1.Value
End Sub

Private Sub Form_Current()
    Me.Calendar1.Value = Now()
    
End Sub

<< MS ACCESS FORM VALIDATION – PT1 | MS Access Validation – PT2 (explained)>>




By the way, if you got or are getting value from the VBA information, please click the "Donate" button to give me a small token of your appreciation, thanks!


These posts may help answer your question too...

Learn Access VBA: Understand Tables, Queries, Forms, and Reports

Learn Access VBA: From Zero to Database Hero If you’ve ever opened Microsoft Access and wondered how all the pieces fit together — tables, queries, forms, and reports — this tutorial is made for you. In just a few minutes, you’ll understand how Access works behind the scenes and see how VBA (Visual Basic for […]

How to Fix Run Time Error 1004 in Excel

If you work with Microsoft Excel frequently, chances ar ling for a solution. Fortunately, this error is well-documented, and there are several ways to resolve it. In this article, we’ll explore the causes of run time error 1004, practical steps to fix it, and preventive measures to reduce the chances of it happening again. What […]

Error 91 Flowchart vbahowto-com

Error 91: Object Variable or With Block Variable Not Set — Causes and Solutions

If you work with VBA (Visual Basic for Applications) in Excel, Access, Word, or other Microsoft Office programs, you’ve probably come across the dreaded Error 91 at least once: Run-time error ‘91’: Object variable or With block variable not set This error can be frustrating, especially if your code seems perfectly fine at first glance. […]

How To Escape Apostrophe In SQL Update Query

If you are looping a table with thousands of records, you’ll probably run into at least one that has an apostrophe in the field name. Like “Mike’s” or “M’cormick”, or something else. Anyway, here is one way to escape the string when you are doing your update query. Option Compare Database Sub YDriveLoop() ‘4/23/24 erik@loeblcomservices.com […]


Support these sponsors:
Previous Post

MS Access Validation – PT2 (explained)

Next Post

Access Forms – Access Default Value

Leave a Reply

Your email address will not be published. Required fields are marked *