473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Table property question

Hey, I've got what seems like a simple question, but I've been
wrestling around with it for way too long. I've got two fields in a
table named [SPW] and [NumPages]. I don't want the user to be able to
enter a SPW (single piece weight) without entering the number of
pages. Since Access doesn't allow me to compare table fields in the
field validation rules (ie, [NumPages] [SPW]), I'm trying to do it
in the table validation and according to everything I've read it's
supposed to work.....but doesn't.

I've got both fields as optional with validation rules of >0. In the
table validation, I've simply got [NumPages] >= [SPW].

Any ideas?
Mar 26 '07 #1
3 1757
Lets assume that you are using a form to interface with this table as
you should be (never let users enter data directly into a table). You
can trap the before insert event to ensure that either both or neither
(if neither being populated is valid) text box is populated and then
take appropraite action.

On Mar 26, 3:06 pm, gmil...@nospam-mobileregister.com (G. Miller)
wrote:
Hey, I've got what seems like a simple question, but I've been
wrestling around with it for way too long. I've got two fields in a
table named [SPW] and [NumPages]. I don't want the user to be able to
enter a SPW (single piece weight) without entering the number of
pages. Since Access doesn't allow me to compare table fields in the
field validation rules (ie, [NumPages] [SPW]), I'm trying to do it
in the table validation and according to everything I've read it's
supposed to work.....but doesn't.

I've got both fields as optional with validation rules of >0. In the
table validation, I've simply got [NumPages] >= [SPW].

Any ideas?

Mar 26 '07 #2
I hear what you're saying, but I've been using a query to allow them
to enter these two values only, as they are really inconsequential to
day-to-day reliability or database integrity. I could use a form I
guess, but it would be cumbersome for this particular process.
On 26 Mar 2007 12:20:04 -0700, "DavidB" <je***@yahoo.comwrote:
>Lets assume that you are using a form to interface with this table as
you should be (never let users enter data directly into a table). You
can trap the before insert event to ensure that either both or neither
(if neither being populated is valid) text box is populated and then
take appropraite action.

On Mar 26, 3:06 pm, gmil...@nospam-mobileregister.com (G. Miller)
wrote:
>Hey, I've got what seems like a simple question, but I've been
wrestling around with it for way too long. I've got two fields in a
table named [SPW] and [NumPages]. I don't want the user to be able to
enter a SPW (single piece weight) without entering the number of
pages. Since Access doesn't allow me to compare table fields in the
field validation rules (ie, [NumPages] [SPW]), I'm trying to do it
in the table validation and according to everything I've read it's
supposed to work.....but doesn't.

I've got both fields as optional with validation rules of >0. In the
table validation, I've simply got [NumPages] >= [SPW].

Any ideas?

Mar 26 '07 #3
On Mar 26, 8:06 pm, gmil...@nospam-mobileregister.com (G. Miller)
wrote:
I've got two fields in a
table named [SPW] and [NumPages]. I don't want the user to be able to
enter a SPW (single piece weight) without entering the number of
pages. Since Access doesn't allow me to compare table fields in the
fieldvalidationrules (ie, [NumPages] [SPW]), I'm trying to do it
in the tablevalidationand according to everything I've read it's
supposed to work.....but doesn't.

I've got both fields as optional withvalidationrules of >0. In the
tablevalidation, I've simply got [NumPages] >= [SPW].
I assume by 'optional' you mean they can accept the NULL value and the
problem is the Validation Rule [NumPages] >= [SPW] is allowing a row
where NumPages is NULL and SPW is not NULL. The behaviour I've
described is correct and by design.

The behaviour was changed in Jet 4.0 (Access2000 and later) to be
compliant with CHECK constraints in the SQL-92 standard, which
specifies:

[quote]

If the <table constraintis a <check constraint definition>, then
let
SC be the <search conditionimmediately contained in the <check
constraint definitionand let T be the table name included in the
corresponding table constraint descriptor; the table constraint is
not
satisfied if and only if

EXISTS ( SELECT * FROM T WHERE NOT ( SC ) )

is true.

[Unquote]

Read that again very carefully!

In a nutshell, SQL exhibits three value logic. Your Validation Rule
[NumPages] >= [SPW] can return three possible results: TRUE, FALSE and
UNKNOWN. In the case when NumPages is NULL and SPW equal 55 the
validation rule will evaluate NULL >= 55 and return UNKNOWN.

Should an UNKNOWN value fail a validation rule? The logic is, UNKNOWN
cannot be known to fail a rule so it is given the benefit of the doubt
and allowed to pass the rule. This behaviour is, I believe, for
pragmatic reasons: if you think about it, the alternative (i.e. a
Validation Rule must evaluate to TRUE) would require explicit tests
for NULL for every nullable column in validation rules and that would
quickly become tiresome.

It could well be the case that what you have read is wrong. Here's one
example I know of:

Access 2000 Project Guide
Chapter 2: Implementing Microsoft Access 2000 Client/Server Databases

http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx

"When writing CHECK constraints, you should consider the following:
CHECK constraints are expressions that evaluate to either true or
false [wrong!], and only when the expressions evaluate to true are the
values accepted [wrong!] for the specified column or columns."

In conclusion: the concept of the NULL (data) value is tricky, many
people remain unaware of the concept of the UNKNOWN *logical* value
and do not realize there's a difference in behaviour between SQL DML
and SQL DDL. Perhaps the best approach is to alter your design to
remove the nullable columns. For inspiration, see:

How To Handle Missing Information Without Using NULL
By Hugh Darwen
http://www.dcs.warwick.ac.uk/~hugh/T...hout-nulls.pdf

FWIW you can test the behaviour is correct for your Validation Rule as
regards the standards as follows (ANSI-92 Query Mode Access/Jet SQL):

CREATE TABLE Test (
NumPages INTEGER,
SPW INTEGER
)
;
INSERT INTO Test (NumPages, SPW)
VALUES (NULL, 55)
;
SELECT T1.NumPages, T1.SPW, EXISTS (
SELECT *
FROM Test
WHERE NOT ( NumPages >= SPW )
) AS validation_result
FROM Test AS T1
;

Remember, "the table constraint is not satisfied if [the result] is
true". In the above example, the 'result' column evaluates to FALSE
therefore the table constraint (Validation Rule) is satisfied for the
values used.

Jamie.

--
Mar 27 '07 #4

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

Similar topics

1
by: Ed | last post by:
hi, My problems are; 1.How can i fix size of table? i create from 800*600 when open up more resolution the table expand follow (i set table property "width =100%" i know this is a my problem ) But...
11
by: Norman L. DeForest | last post by:
Am I misunderstanding the CSS specifications or is Firefox (version 1.0.6) (and Opera) doing the wrong thing? It appears that Firefox 1.0.6 includes the border in width calculations for tables...
2
by: LaurenW | last post by:
Hi folks, I just discovered that I have a table with a bunch of text fields that ALL have the "Allow Zero Length" property set to "No", which is apparently the default when you create a new text...
3
by: CAD Fiend | last post by:
Hello, I have a land development project that has a many-to-many relationship. I have ONE question regarding table structures, and ONE question on how to make a Form with two Subforms, below. ...
7
by: Stan Sainte-Rose | last post by:
Hi, I use this bit of code to generate dynamic tables in the page load section .... Dim ntable as New Table For i = 1993 To 2008 ntable = New Table ntable.ID = "Q" + i.ToString .... ....
7
by: klynn | last post by:
I'm wondering what the best way to do the following: I have a page with a table. I built a custom class that creates a System.Web.UI.WebControls table object and return it to the webpage as a...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
5
by: eBob.com | last post by:
I am so frustrated. I've been working all weekend on what I thought would be a simple script. I never find it easy to look at someone else's code, but if someone can help with this I would be...
5
by: agarwasa2008 | last post by:
Hi, I have a linked table called tbltest and some bounded forms (which add, update, delete records) that were created using that linked table. For some necessary reasons I had to create another...
8
by: Bob Altman | last post by:
Hi all, This has got to be a dumb question, but... What is the CSS property that I would use to center a table on the web page? If I set the table's Align property in the VS 2008 property...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.