473,666 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validation rule leak

115 New Member
Hi i'm working on storing shoes so each article number had a size , and in my database i'm working that every article had different sizes, and since each article had max 5 sizes for example , i added 5 fields to the item table (st_q1,...st_q5 )
here is the item table (article,price, totStock,st_q1, st_q2,st_q3,st_ q5)

i'm working on the form to enter items to stock by quantity sizes.that form contain txtArticle bound to Article in OrderDetail table. and 7 check boxs
the 1st one represent the total quantity need to be entered ( txtQuantity) and it's bound to the totQty in the table OrderDetail. the second one represent the total stock of that article txtStock bound to the field StockQty in item table.and the 5 txt box represents the quantity of article for each size (txtq1, txtq2, txtq3, txtq4, txtq5).

so in this form i have one txtTot bound to a field in a table, and 5 others txtq1, txtq2, txtq3, txtq4, txtq5. i want to be able to just enter qty = txtTot , not less or more that txtTot,
i tried this validation rule on txtq1, txtq2, txtq3, txtq4 and txtq5:
Expand|Select|Wrap|Line Numbers
  1. [q1]+[q2]+[q3]+[q4]+[q5]+[q6]+[q7]+[q8]+[q9]+[q10]<=[quantity]
this just make sure that i dont enter a sum(qi)>txtTot
but that dont work if the sum(qi) < txtTot, cause if sum(qi) < txtTot the record still save in the database. any help please !
Aug 7 '10 #1
9 1574
Delerna
1,134 Recognized Expert Top Contributor
I have trouble following your post
But, if your rule is
not less or more than
then that must mean the rule is really

must be equal to

so
Expand|Select|Wrap|Line Numbers
  1. [q1]+[q2]+[q3]+[q4]+[q5]+[q6]+[q7]+[q8]+[q9]+[q10]=[quantity] 
  2.  
should work

If you think about the rule you wrote it should be obvious why it was doing what you described because that is exactly what you told it to do
the sum(qi) must be less than or equal to quantity
before the record can be saved
Aug 9 '10 #2
hannoudw
115 New Member
yes i tried that but still not working
i will tell exactly what i'm doing, maybe you could help me. well on each txtqi i wrote in the validation rule that:
Expand|Select|Wrap|Line Numbers
  1. [q1]+[q2]+[q3]+[q4]+[q5]+[q6]+[q7]+[q8]+[q9]+[q10]<=[quantity]
it works just fine but here the problem
for example 1st i need to enter the quantity = 10 (for example) after that i enter in the txtq1 (4) , and in the txtq2 (3) and in the txtq3 (4) when i want to add something in the txtq4 the validation text will pop up cause 4+3+4 = 11 > 10 and that's false.
but see this example (quantity = 10 , txtq1=4,txtq2=1 ) and it also save it without prompting a alert message ... but 5#10.
I also tried that one on each txtqi
Expand|Select|Wrap|Line Numbers
  1. q1]+[q2]+[q3]+[q4]+[q5]+[q6]+[q7]+[q8]+[q9]+[q10]=[quantity] 
and this always gives the validation text. like for example if quantity=10 and i start to put anything in the txtq1, it gives the error , even if i put txtq1=10!!!
Aug 9 '10 #3
hannoudw
115 New Member
Hi i just figure it out how can i do it ...
but i don't know if i'm doing it right .
i put this code on the after update of the txtq10
Expand|Select|Wrap|Line Numbers
  1. Dim Qty, sum As Integer
  2. quty = Me.Qty
  3. sum = Nz(Me.q1, 0) + Nz(Me.q2, 0) + Nz(Me.q3, 0) + Nz(Me.q4, 0) + Nz(Me.q5, 0) + Nz(Me.q6, 0) + Nz(Me.q7, 0) + Nz(Me.q8, 0) + Nz(Me.q9, 0) + Nz(Me.q10, 0)
  4. If (quty < sum) Then
  5. MsgBox "check the Quantity. qty < sum"
  6. q1.SetFocus
  7. End If
  8. If (quty > sum) Then
  9. MsgBox "check the Quantity. qty > sum"
  10. q1.SetFocus
  11. End If
this had worked ... but still i have a problem if i entered for example this: quantity=10
txtq1=2
txtq2,txtq3,... ,txtq10=2
that's would be wrong and this MsgBox "check the Quantity. qty < sum" will appears
the focus is now on the txtq1. (q1.SetFocus)
so if i just modify the txtboxs without modifying the txtq10 , the wrong quantity will save without message alert because i just wrote the validation on the txtq10 after update.
I did try to write the same code on each txtq(i) but everytime that i try to modify the qty i got the alert message and the focus will go to the txtq1.

and what if i just modify one txtq(i), and i pressed enter all the way that will not enter in the after update txtq10 cause txtq10 will not be updated neither changed .. any one can help me please!!
Aug 9 '10 #4
Delerna
1,134 Recognized Expert Top Contributor
Actually, thinking upon what you are doing the way you are trying to setup the rule appears to be a sort of circular refernce.

the rule
txtq1+txtq2+txt q3+txtq4+txtq5= txtQty

if we start with
1+1+1+1+1=5

and you want to change
txtq1=2
if you try to change txtqty to 6 first
the rule on will kick in and prevent it
if you try to change txtq1 first the rule will kick in an prevent it.


I think you would be better off making the txtQty textbox uneditable and then on txtq1 etc ... putting some code in the after update event that adds up the values in txtq1 etc and updates txtQty automatically.
Aug 9 '10 #5
Delerna
1,134 Recognized Expert Top Contributor
My suggestion above is based on what you currently have as your table set up and I tend to just answer peoples questions.
However I feel I should point out a basic mistake you are making
You really should be designing tables that grow vertically instead of horrizontally.

HORIZONTAL GROWTH
(article,price, totStock,st_q1, st_q2,st_q3,st_ q5)

For example, what if in two years time they come out with a 6th size. A developer will have to go back into the database and add a 6th field to the table to accomodate the new size.
They will also have to update any queries, forms,reports that use that table. Extra rules will need to be added or extra after update events added. That is the draw back of horizontal growth. The new sizes must be added as new fields and there is then a lot of work updating everything else to accomodate the new fields


VERTICAL GROWTH
With vertical growth the new size will be added as a new record by a user and all the queries,forms and reports have been developed with vertical growth in mind and the new size will be automatically catered for. There should be no need for a developer to come back and make the addition

HOW?
I will keep the design simple rather than correct.

THE TABLE FIELDS
(article,price, Size,Stock)

THE RECORDS
DesertBoot,$10, 1,5
DesertBoot,$10, 2,1
DesertBoot,$10, 3,6
DesertBoot,$10, 4,2
DesertBoot,$10, 5,0

Notice how the sizes are growing vertically
To add a new size it is a simple matter of adding a new record and your form to update the stock will be a list of all the sizes of desertboot. TotalStock is also missing, this should be a calculated field that only exists in queries and forms and not in the table. Its value is calculated.




THE NEXT STEP....NORMALI ZE
Identical values should be moved to their own table. Notice in the above data DesertBoot and $10 is repeated for each size. This is a waste of space so.

THE TABLES
table1 (articleID,arti cle,price)
table2 (articleID,Size ,Stock)

THE DATA
table1
------
1,DesertBoot,$1 0
2,SandShoe,$5

table2
------
1,1,5
1,2,1
1,3,6
1,4,2
1,5,0
2,1,0
2,2,0
...


Anyway, thats the basics of "Effective Design"

There are plenty of articles about all of this on the internet and there is one on our site also
Aug 10 '10 #6
hannoudw
115 New Member
My data base was like that . but the thing is that i'm making this project depending on some one's need "It's my father :D " .
so he want when the form open and he choose the article to not insert the every size of the article, and the sizes of shoes are the same , and i don't think that there will be a new size more in the 50 or 100 years , anyway he just want when he open the form to add quantities to stock to see all the sizes and just fill the quantities of each size .
and i tried so many difficulties when i had the structure of table like you mentioned , cause every time that he choose a article i couldn't manage to see all the sizes of this article cause he need to fill them first .
I indeed appreciate your help, but if you see another way of doing this without making a form that enter all the sizes for every article by the user i'm listening !
Aug 10 '10 #7
Delerna
1,134 Recognized Expert Top Contributor
I agree that in this case it is unlikely that extra sizes of shoe will need to be added and I myself will break the "propper" database development rules if I see a benefit in doing so.

My post on propper database design was something I felt obliged to mention in case you were not aware. It wasn't meant to say you must develop that way, the choice is yours.

Just to answer the problems with this type of table structure. This is usually achieved through form/subform solutions.

The form will have the fields from table1 and you navigate through each record of table1 one at a time.
Inside the main form there is
a second form (called a subform) that displays only the records from table2 that relate to the current record on the main form.

New articles are added and updated through the fields on the main form and article sizes are added removed and updated through the fields on the sub form.

With this technique article1 might have say.. 1 size record attached to it. Article2 might have 3 size records attached to it etc etc.
You can add as few or as many size records to any particular article record as required
Aug 10 '10 #8
Delerna
1,134 Recognized Expert Top Contributor
incidentally, did you try the idea from post 5 in your current design? Will it work for you?
Aug 10 '10 #9
hannoudw
115 New Member
Question:
@Delerna
I'm thankful of your effort to help me.
And about #5 :

I'm still working on it and still not working, I just wanna keep the txtqty unlocked cause i wanna be able to modify the total quantity, and if i use the #5 i will not know if i did a mistake and i added more then the real quantity to stock.

For example if i have 10 items from the article1 and they are decomposed to: 1 item of the size1
2 items of the size2
2 items of the size3
1 item of the size4
1 item of the size5
1 item of the size6
2 item of the size7

And by any mistake i did entered this (1,1,2,1,1,1,2, 1)
as the quantity of every item, and i didn't notice that i entered less quantity.

But if i make sure to enter the total quantity number at the first place and after the quantity of every size. I'll be able to manage that possible mistake by checking if the total is equal to the sum of txtq(i).

And I solve it . I transfer the continuous form to a single form and i add a button with a click event to add the items to stock when quantity=Sum(qi ) and it works!!

Thanks again for the team help :)
Aug 11 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4270
by: Dalan | last post by:
This ought to be simple enough, but not certain which to use. I have a few fields set to Require data to be entered; however, the message displayed by Access 97 is too generic to be of any real value. I tried attaching a specific message for this in the table properties, but was unsuccessful. Can this be done? I then opted for Not Is Null as the Validation Rule and with specific Validation Text. That was better up to a point and assume...
2
2683
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 trouble though creating a validation rule for one of my fields. I have a table called "Product" and two of the fields included in this table are "Cost Price" and "Retail Price". I need to create a validation rule so that the Cost Price is always less than the Retail Price. I have tried...
2
1723
by: Danny | last post by:
I created a function to test to see if entered text has a '.' in it, The code seems to work but the validation always fails even when 'true' is returned. i put = myfunction in the validation rule and ny validation messages always displays. What am I doing wrong
3
4074
by: GGerard | last post by:
Hello In a text box, I would like the user to be able to enter only a number from 0 to 100 (including decimals Ex: 24.56) so I wrote this in the Validation Rule Propertie of the text box : >= 0 And <=100 This works good when the user enters numbers in the text box but when letters are entered Access displayed a default message instead of the Validation Text message.
6
3685
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 table tblC. A form based on tblA is used to add new records. The Validation Rule: <>!! was made using the expression builder. The rule produces this error: The expression you entered in the Form control's Validation Rule doesn't contain the Automation object 'Tables' If I use simply: ...
4
2714
by: ron | last post by:
I have a access based guest book. I want to create a validation rule to block certain words or parts of a srting. How do i do this? ie: this is a nice site. come visit my porn site at www.abc.zy If the message contains the word porn, can I block the whole message using a validation rule
10
5714
by: gweasel | last post by:
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...
3
1284
by: KPR1977 | last post by:
I want to set a validation rule that will not allow me to input data in field1 in TableA that is not found in TableB under field2. Basically, Table B under field 2 has the following row entries: Apple, Pear, Lemon, Orange. When I input data in field 1 for Table A I want it to give me an error message if try and input Watermelon (since Watermelon doesn't exist anywhere in Table2.) If anyone could help me out with this, it would be much...
12
24837
alakazamm
by: alakazamm | last post by:
I am building a database on Access 2000 which include a Customer Details table. In this Customer Details table there is a 'Post Code' field which I am required to make an Input Mask to limit the values. I have used the following Input Mask: LL##&AL? This Input Mask should be able to contain the following types of Post Code: LE4 5GH
1
2080
by: MLH | last post by:
Anyone remember if A97 append query failure would ever report data breaking validation rule when such was not the case. I have an old SQL statement - several years old now. I've encountered a case in which the append fails and the reported error is validation rule. The table being appended to (tblClusters) has only 1 field with a validation rule: , with Byte Field Size property setting. The validation rule is >0. The field's default...
0
8443
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.