If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Validation Rule

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-12, 12:03
CHI Brian CHI Brian is offline
Registered User
 
Join Date: Mar 2009
Posts: 72
Validation Rule

Hello Everyone,

I am hoping someone can assist me here. I am creating a Form on a database that I have. There are a couple of Fields that I want to Validate based on the value in 1 or 2 other fields in the same table but I can not figure out the syntax of the expression on the Validation Rule.

The First one I wish to validate is a Y/N field. the Y value should only be present if the Department field is equal to 7010 or 7190 otherwise it should be N. The Default value of the field is N.

The Second one I want to Validate is the "Old Price" field. This field should have a value Greater then 0 IF, the Action Field is "Edit" and the "Price Change" Check box is True.

Can someone help me with Syntax on this. I've tried using IIF but it doesn't seem to like that or I am not typing it correctly.

Thank you!
Reply With Quote
  #2 (permalink)  
Old 01-23-12, 13:15
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
IIRC validation rules in Access are usually applied to the column in th etbael, so you cna check to ensure the value of tghat column is sane, but I don't think you cna base the validation on the value of another column at table level.. you have to apply those rules in the form, usually in a before update event

you have the option of setting the value automatically

eg in the forms before update event
if mycontrol.value = 7010 or 7090 then
mybooleancontrol.value = true
else
mybooleancontrol.value = false
endif


for the old price, Im guessing you want to force someone to do something
if so thats in the forms on current event (which triggers when a fresh record is displayed
if myoldprice.value = 0 then
'whatever action field is = edit
'whatever pricechange is = true
else
'insert code here to handle where myoldprice <>0 if required
endif
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 01-23-12, 14:33
CHI Brian CHI Brian is offline
Registered User
 
Join Date: Mar 2009
Posts: 72
Okay. Thank you very much. I have the Value's setting in a Query when I pull the data out to be loaded into another program so I will have to rely on that for the first part.

The second part, I will have to watch carefully then. I did find soemthing in the Help that says you can not base a validation rule on another field.

THanks anyway, was worth a shot.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On