Solved

Validation rules in properties not working as I think they should

Posted on 2015-02-23
3
188 Views
Last Modified: 2015-02-23
I have a control on a form tied to a number field in a table. I am attempting to set a validation rule and validation text which would prevent a record being created without a number in this control. I am using "<>0" for my validation rule, and validation text that says something like "Please enter a quantity before continueing.

I have tried this, as well as "Is Not Null" for a validation rule, and neither one seems to work, as I'm able to breeze right by the quantity control without entering a value with no message or validation occuring.

Is there a better way to make this control a "required" item in my form? My desire is to have the the focus remain on the quantity control until a valid number is input.
0
Comment
Question by:Shooter54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 40627006
use the before update event of the form
private sub form_beforeUpdate(cancel as integer)

if me.txtQuantity & ""=""  or me.txtquantity = 0 then
   msgbox "Quantity is required"
   Cancel=true
  me.txtQuantity.setFocus
  exit sub
end if

end sub
0
 
LVL 37

Assisted Solution

by:PatHartman
PatHartman earned 250 total points
ID: 40627018
The ONLY event where you can reliably check for "empty" controls is the FORM's BeforeUpdate event.  If the user never places focus in the control in question NO control level event will work because none would ever fire.  Same for the validation rules.  Although the validation rule will pick up the not null condition before the record is saved.  

So, unless you want to put code in EVERY event, you need to content yourself with the code Rey suggested.  All validation code of this type and also any that relies on multiple controls should always be done in the FORM's BeforeUpdate event.
0
 

Author Closing Comment

by:Shooter54
ID: 40627148
Thanks guys.... great advice that worked like a dream.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question