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 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 […]

How To Make An Access Form Time Picker

Here is a relatively easy way to select times for your time entry text boxes. It’s a reusable form that allows you to pick a time from an Access form. There are probably different ways to do this but here is the way I would do it. On the form that has the time fields, […]

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 […]

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 *