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 give me a tip, thanks!


These posts may help answer your question too...

How To Parse A Flat File In Excel VBA

In another post I demonstrated how to access a file on your computer using the MS Office Library. Here it is if you don’t know what I’m talking about. In this post, I am going to show you how to access the file and load it into your spreadsheet. I will do the same thing […]

How to pick a file to load In VBA

Picking a file to load in your Microsoft App is a very important skill to know. In this blog post you will see how to do it. First you need to set a reference to the MS office object library From VBE editor –> select Tools > MS office object library (click check mark) Sub […]

What is the purpose of the Me keyword in Access VBA?

What does the Me keyword mean? “Me” refers to the Access form currently in focus. Instead of writing out the entire form reference, you can just use the keyword “Me” which is easier. Like: Me.txtbox = “I am a textbox on the form that currently has the focus.” or you can update a label’s caption […]

How do I handle errors in Access VBA code?

I am going to give you the answer to “How do I handle errors in Access VBA code?” In my opinion there are 2 ways to handle errors: 1. Avoid the potential for an error to occur. 2. Handle the error in your code. Number 1 – If you have a control on your form […]

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 *