472,353 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Validation Rule on Table Field vs Form Control

What is the best way to apply a Validation Rule - or rather, where is
the best place to put it? Is there an advantage to putting it on the
field in the table vs setting the validation rule on the form the
control is on?

Basically I have a number of controls in a form that are required, and
to check it I am setting the Validation Rule to "<>"IsNull" so that
when the user tries to tab through/click out of a required area
without entering anything, they are alerted. I noticed though, after
I'd set up a few controls on the form this way, that the same settings
are also available when creating the table that drives the form.

Just curious and want to fix possible problems before I release the
system to the end users.

Thanks.

Mar 7 '07 #1
10 5517
gweasel wrote:
What is the best way to apply a Validation Rule - or rather, where is
the best place to put it? Is there an advantage to putting it on the
field in the table vs setting the validation rule on the form the
control is on?

Basically I have a number of controls in a form that are required, and
to check it I am setting the Validation Rule to "<>"IsNull" so that
when the user tries to tab through/click out of a required area
without entering anything, they are alerted. I noticed though, after
I'd set up a few controls on the form this way, that the same settings
are also available when creating the table that drives the form.

Just curious and want to fix possible problems before I release the
system to the end users.

Thanks.
In an all-in-one single user system it makes very little difference. In a
business app though it is best to look at the database as a stand-alone entity.
One that exists as a resource unto itself and which could be accessed by
multiple interfaces, not just the front end that you create for it in Access.

When looked at that way then you want as many of the rules as possible to be
defined at the data engine level so that they are enforced regardless of what
program might interact with the data.

This is the default mind-set when building server databases in SQL Server,
Oracle, etc., since those are purely database engines and the guy who sets up
the database usually has nothing to do with building the applications that will
interact with it. When building database applications with Access this doesn't
isn't always so obvious, but it is still the best practice.

The most simple example is that even in an all-in-one single user application
you could build multiple forms that all are bound to the same table. Do you
want to repetitively build those rules into each and every one of those forms,
or do it once in the table and be done with it?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Mar 7 '07 #2
Hi,

IMHO, it sounds like it would just be easier to set the "Required" property
to "Yes" in the table design view in a case like this.

HTH,
Don
"gweasel" <ba*****@yahoo.comwrote in message
news:11**********************@64g2000cwx.googlegro ups.com...
What is the best way to apply a Validation Rule - or rather, where is
the best place to put it? Is there an advantage to putting it on the
field in the table vs setting the validation rule on the form the
control is on?

Basically I have a number of controls in a form that are required, and
to check it I am setting the Validation Rule to "<>"IsNull" so that
when the user tries to tab through/click out of a required area
without entering anything, they are alerted. I noticed though, after
I'd set up a few controls on the form this way, that the same settings
are also available when creating the table that drives the form.

Just curious and want to fix possible problems before I release the
system to the end users.

Thanks.

Mar 7 '07 #3
I have set the Required property to yes and moved the validations to
the table level instead of the form level. I like to have the
validation rules in effect though because the error messages that come
up when only the Required property are set are not helpful to the end
user (they refer to the field name as "[Tbl_Name].[Field_Name]" and
that is confusing to the users.

I am actually having an issue though. I swear this was working
earlier in the week, but even before moving the rules to the table
level, when I went through to test the system, I am able to breeze
right through the supposedly required fields/controls. Now, if I am
switching from a form to the subform, I get the unhelpful "required
property" error message, but never see the validation text I typed
out. And ideally, I'd want this message to pop up when they are
trying to exit the required control on the form rather than when
they're trying to exit another control to get into a subform. For
example, "Due Date" is required, but it is 5 tab stops away from my
subform. They can tab/click right past "Due Date" and never know they
missed something that was required until 5 steps later. I think this
is adding to confusion as well - since they're most likely going to
look in the last field they were in to try and fix the problem, when
in reality, they need to go back farther than that.

Make sense? Any idea how I can have these messages pop up "On exit"
basically, without coding? If coding is needed, I guess that's fine,
but please give me some hint as to what I need to make it work and
give the user a custom message instead of the default messages Access
gives.

Thanks.

On Mar 7, 6:03 am, "Don Leverton" <leveriteNoJunkM...@telusplanet.net>
wrote:
Hi,

IMHO, it sounds like it would just be easier to set the "Required" property
to "Yes" in the table design view in a case like this.

HTH,
Don

"gweasel" <bane...@yahoo.comwrote in message

news:11**********************@64g2000cwx.googlegro ups.com...
What is the best way to apply a Validation Rule - or rather, where is
the best place to put it? Is there an advantage to putting it on the
field in the table vs setting the validation rule on the form the
control is on?
Basically I have a number of controls in a form that are required, and
to check it I am setting the Validation Rule to "<>"IsNull" so that
when the user tries to tab through/click out of a required area
without entering anything, they are alerted. I noticed though, after
I'd set up a few controls on the form this way, that the same settings
are also available when creating the table that drives the form.
Just curious and want to fix possible problems before I release the
system to the end users.
Thanks.

Mar 7 '07 #4
Table validations are applied when you write the Record, and that's what
happens when you go from a main Form to the Form embedded in a Subform
Control. You can "protect yourself" with Table-level validation and _also_
protect your users from unfriendly error messages, by _also_ including
validation in VBA code in the AfterUpdate of Controls on the Form. (Yes, I
know -- extra work... frustrating, isn't it?)

Larry Linson
Microsoft Access MVP

"gweasel" <ba*****@yahoo.comwrote in message
news:11********************@30g2000cwc.googlegroup s.com...
>I have set the Required property to yes and moved the validations to
the table level instead of the form level. I like to have the
validation rules in effect though because the error messages that come
up when only the Required property are set are not helpful to the end
user (they refer to the field name as "[Tbl_Name].[Field_Name]" and
that is confusing to the users.

I am actually having an issue though. I swear this was working
earlier in the week, but even before moving the rules to the table
level, when I went through to test the system, I am able to breeze
right through the supposedly required fields/controls. Now, if I am
switching from a form to the subform, I get the unhelpful "required
property" error message, but never see the validation text I typed
out. And ideally, I'd want this message to pop up when they are
trying to exit the required control on the form rather than when
they're trying to exit another control to get into a subform. For
example, "Due Date" is required, but it is 5 tab stops away from my
subform. They can tab/click right past "Due Date" and never know they
missed something that was required until 5 steps later. I think this
is adding to confusion as well - since they're most likely going to
look in the last field they were in to try and fix the problem, when
in reality, they need to go back farther than that.

Make sense? Any idea how I can have these messages pop up "On exit"
basically, without coding? If coding is needed, I guess that's fine,
but please give me some hint as to what I need to make it work and
give the user a custom message instead of the default messages Access
gives.

Thanks.

On Mar 7, 6:03 am, "Don Leverton" <leveriteNoJunkM...@telusplanet.net>
wrote:
>Hi,

IMHO, it sounds like it would just be easier to set the "Required"
property
to "Yes" in the table design view in a case like this.

HTH,
Don

"gweasel" <bane...@yahoo.comwrote in message

news:11**********************@64g2000cwx.googlegr oups.com...
What is the best way to apply a Validation Rule - or rather, where is
the best place to put it? Is there an advantage to putting it on the
field in the table vs setting the validation rule on the form the
control is on?
Basically I have a number of controls in a form that are required, and
to check it I am setting the Validation Rule to "<>"IsNull" so that
when the user tries to tab through/click out of a required area
without entering anything, they are alerted. I noticed though, after
I'd set up a few controls on the form this way, that the same settings
are also available when creating the table that drives the form.
Just curious and want to fix possible problems before I release the
system to the end users.
Thanks.


Mar 7 '07 #5
On Mar 7, 2:24 pm, "Larry Linson" <boun...@localhost.notwrote:
Table validations are applied when you write the Record, and that's what
happens when you go from a main Form to the Form embedded in a Subform
Control. You can "protect yourself" with Table-level validation and _also_
protect your users from unfriendly error messages, by _also_ including
validation in VBA code in the AfterUpdate of Controls on the Form. (Yes, I
know -- extra work... frustrating, isn't it?)

Larry Linson
Microsoft Access MVP

"gweasel" <bane...@yahoo.comwrote in message

news:11********************@30g2000cwc.googlegroup s.com...
I have set the Required property to yes and moved the validations to
the table level instead of the form level. I like to have the
validation rules in effect though because the error messages that come
up when only the Required property are set are not helpful to the end
user (they refer to the field name as "[Tbl_Name].[Field_Name]" and
that is confusing to the users.
I am actually having an issue though. I swear this was working
earlier in the week, but even before moving the rules to the table
level, when I went through to test the system, I am able to breeze
right through the supposedly required fields/controls. Now, if I am
switching from a form to the subform, I get the unhelpful "required
property" error message, but never see the validation text I typed
out. And ideally, I'd want this message to pop up when they are
trying to exit the required control on the form rather than when
they're trying to exit another control to get into a subform. For
example, "Due Date" is required, but it is 5 tab stops away from my
subform. They can tab/click right past "Due Date" and never know they
missed something that was required until 5 steps later. I think this
is adding to confusion as well - since they're most likely going to
look in the last field they were in to try and fix the problem, when
in reality, they need to go back farther than that.
Make sense? Any idea how I can have these messages pop up "On exit"
basically, without coding? If coding is needed, I guess that's fine,
but please give me some hint as to what I need to make it work and
give the user a custom message instead of the default messages Access
gives.
Thanks.
On Mar 7, 6:03 am, "Don Leverton" <leveriteNoJunkM...@telusplanet.net>
wrote:
Hi,
IMHO, it sounds like it would just be easier to set the "Required"
property
to "Yes" in the table design view in a case like this.
HTH,
Don
"gweasel" <bane...@yahoo.comwrote in message
>news:11**********************@64g2000cwx.googlegr oups.com...
What is the best way to apply a Validation Rule - or rather, where is
the best place to put it? Is there an advantage to putting it on the
field in the table vs setting the validation rule on the form the
control is on?
Basically I have a number of controls in a form that are required, and
to check it I am setting the Validation Rule to "<>"IsNull" so that
when the user tries to tab through/click out of a required area
without entering anything, they are alerted. I noticed though, after
I'd set up a few controls on the form this way, that the same settings
are also available when creating the table that drives the form.
Just curious and want to fix possible problems before I release the
system to the end users.
Thanks.
It's not that much extra work - just one of those things I thought
(like so many others) would be included in the properties or regular
functions. But, alas, coding it is. Thanks for the advice and
explanations.

Mar 7 '07 #6
The question here really is, are you satified with your users getting the
rather unhelpful (as was metioned) Access messages about validation having
been failed (if set on the table level) or do you want them to receive a
cogent message that you've written (if validation is done on the form level)
explaining what they need to do. I deal solely with non-power users, and
always do validation on the form level, with simple, clear explanations of
what hasn't been done and howw to correct it.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200703/1

Mar 8 '07 #7
missinglinq via AccessMonster.com wrote:
The question here really is, are you satified with your users getting
the rather unhelpful (as was metioned) Access messages about
validation having been failed (if set on the table level) or do you
want them to receive a cogent message that you've written (if
validation is done on the form level) explaining what they need to
do. I deal solely with non-power users, and always do validation on
the form level, with simple, clear explanations of what hasn't been
done and howw to correct it.
When I am worried about that (which is usually) I do both. One is important and
one is "frosting".

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Mar 8 '07 #8
"Rick Brandt" <ri*********@hotmail.comwrote in
news:ne*************@newssvr29.news.prodigy.net:
missinglinq via AccessMonster.com wrote:
>The question here really is, are you satified with your users
getting the rather unhelpful (as was metioned) Access messages
about validation having been failed (if set on the table level)
or do you want them to receive a cogent message that you've
written (if validation is done on the form level) explaining what
they need to do. I deal solely with non-power users, and always
do validation on the form level, with simple, clear explanations
of what hasn't been done and howw to correct it.

When I am worried about that (which is usually) I do both. One is
important and one is "frosting".
I would say one is essential and the other is helpful.

If you're validating it at the form level, insofar as is possible,
the underlying table should already have validation rules for the
same thing defined.

Why?

Because you can't always know for certain that all your data will be
entered through that particular form.

This is why we use RI at the engine level.

It's why we use any data integrity enforcement at the engine level.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Mar 8 '07 #9
On Mar 8, 4:09 am, "David W. Fenton" <XXXuse...@dfenton.com.invalid>
wrote:
If you're validating it at the form level, insofar as is possible,
the underlying table should already havevalidationrules for the
same thing defined.

Why?

Because you can't always know for certain that all your data will be
entered through that particular form.
Another reason is you can't be sure your form is, and will always be,
bug free.

Jamie.

--
Mar 8 '07 #10
On Mar 7, 9:24 pm, "Larry Linson" <boun...@localhost.notwrote:
Table validations are applied when you write the Record, and that's what
happens when you go from a main Form to the Form embedded in a Subform
Control. You can "protect yourself" with Table-level validation
[Slightly picky] It may be referred to as a "Table Validation Rule"
and be defined it the table's property pages in the Access UI but it
is not actually table-level. Rather, it is record-level because it can
only refer to values in the same record (row).

A ACE/Jet CHECK constraint, however, is genuinely table-level because
it can refer to values on other rows in the same table. FWIW, although
it can additionally refer to values in other tables, it is not
actually schema-level because its table must be targeted by the INSERT/
UPDATE/DELETE statement for the constraint to be checked.

Jamie.

--
Mar 8 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dalan | last post by:
I apparently need a bit of assistance regarding the structure of some validation code on the BeforeUpdate or AfterUpdate event on a form for...
2
by: Joey P | last post by:
Hi all, I am doing a project for university whereby i have to implement a simple database related to a frozen foods company. I am having some...
2
by: Tony Williams | last post by:
I am validating two text boxes to make sure they contain data. I have use Is Not Null in the Validation Property of the control but it doesn't seem...
18
by: Steve | last post by:
Hi I have a really weird problem and any assistance would be welcome. I have developed an app in Access 2002. The app runs perfectly on the...
2
by: Kostas | last post by:
Just a quick question on this issue. Assume a small set of fixed values for a field. For instance Field Gender, values: Male, Female, Unknown If...
6
by: Chuck | last post by:
A97. A database has a table: tblA which has a single text field, B. It is a primary field, indexed and no duplicates. It is used as a lookup for...
5
by: Don Sealer | last post by:
I've got a validation rule that says something like =xx or xxx or zzzz. Though I may not have described it well it does work fine and that is...
3
by: BrianB830 | last post by:
Hello all, I have a quick question regarding an MS Access database I'm creating. In the entity "ORDER", I have the attributes "Order Date"...
7
by: sharsy | last post by:
Hi guys, I would like to setup a validation rule for a database in microsoft access that restricts data entry so that a certain field can only be...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.