Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Question for a validation rule in access 2007
Richard 

16 years ago
I'm new and trying to add a validation rule to the country field. The rule be set so that if the country is Not USA, the following message should appear. "Be sure to use the country code when calling outside the USA".

Basically if you type in USA, you shouldn't get a message but I'm stuck.


Answer from Richard Rost:

This is not exactly what the validation rule is used for. The VR message pops up if the user enters invalid data for the field. For example, if you have a "number of children" field and the user types in -1, then you can yell at them.

For what you want to do, you're going to need a custom event. It's not hard, but you need to do it right. I would make an AfterUpdate event for the Country field… something like this:

If Country <> "USA" then
   msgbox "Make sure…"
end if

That's it. Here's a tutorial to help you out with AfterUpdate events:

You can use an AfterUpdate or BeforeUpdate event to set values, change properties, run macros, and do lots of other cool things.

The major difference between the two is that BeforeUpdate runs BEFORE the data is saved to the table, which allows you to CANCEL the update if the data is not valid. AfterUpdate runs after the data is saved to the table.

Please see the following FREE video tutorial on my web site for step-by-step instructions on how to create an AfterUpdate event:

http://599cd.com/tips/access/afterupdate-event-vba?key=BlFAlEx

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/9/2026 2:01:15 PM. PLT: 1s