By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,510 Members | 1,497 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,510 IT Pros & Developers. It's quick & easy.

Validation rule in table properties

P: 2
Hello!
I have a problem with this table PRODUCTS, it has the following fields:
-Product id: Number, single, primary key
-Status: validation rule with the following restrictions: in stock, finished, in supply
Supply Date: Date/Time, Short date
And the Supply Date cannot be before the current date and it is specified only for those products with status “in supply. How do I write this validation rule in Table Properties?
Please help! I am desperate

Alexandra
Jan 13 '07 #1
Share this Question
Share on Google+
4 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Hello!
I have a problem with this table PRODUCTS, it has the following fields:
-Product id: Number, single, primary key
-Status: validation rule with the following restrictions: in stock, finished, in supply
Supply Date: Date/Time, Short date
And the Supply Date cannot be before the current date and it is specified only for those products with status “in supply. How do I write this validation rule in Table Properties?
Please help! I am desperate

Alexandra
You cannot write this rule in table properties. You can only validate data entry through the use of a form.

Mary
Jan 13 '07 #2

P: 2
You cannot write this rule in table properties. You can only validate data entry through the use of a form.

Mary
Great, how do I do that..what do I do actually?
Jan 13 '07 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
Great, how do I do that..what do I do actually?
On your form in the Supply Date textbox where the user enters a date open the properties window and put in the validation rule property

Expand|Select|Wrap|Line Numbers
  1. >=Date()
This won't allow the use to enter a date prior to the current date.

The 'In Supply' rule is a little more complicated.

You will need to create two event procedures.

You will need to put the following code in the forms On Current event and the other on the Status textboxes After Update event.

Expand|Select|Wrap|Line Numbers
  1. If Me.[Status] = "In Supply" Then
  2.    Me.[Supply Date].Enabled = True
  3. Else
  4.    Me.[Supply Date].Enabled = False
  5. End If
  6.  
This will disable the textbox unless the product is In Supply.

Mary
Jan 13 '07 #4

NeoPa
Expert Mod 15k+
P: 31,186
This should also work and is a little more compact :
Expand|Select|Wrap|Line Numbers
  1. Me.[Supply Date].Enabled = (Me.[Status] = "In Supply")
Jan 14 '07 #5

Post your reply

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